SamsonChung
asked on
What am I forgetting in this code? It must be something simple!!
Ok, I did the following on a Windows Xp machine running Java 1.5
%JAVA_HOME%\bin\javac omega.java
%JAVA_HOME%\bin\java omega
JVM returned
Exception in thread "main" java.lang.NoClassDefFoundE rror: omega
My directory consists of two files
omega.java
omega.class
What am I doing wrong?
My code is attached.
%JAVA_HOME%\bin\javac omega.java
%JAVA_HOME%\bin\java omega
JVM returned
Exception in thread "main" java.lang.NoClassDefFoundE
My directory consists of two files
omega.java
omega.class
What am I doing wrong?
My code is attached.
public class omega{
public omega(){
System.out.println("this is a test");
}
public static void main(String[] args){
new omega();
}
}
try setting classpath as
set classpath=%classpath%;%JAV A_HOME%\bi n;.;
set classpath=%classpath%;%JAV
ASKER
.....That's what I thought! There is nothing wrong with that code!!
The only question remains is why doesn't it work?
Thanks guys, but ur suggestions were already attempted. (its not like I am haven exhausted my own mind before posting on here...)
Uros, that's how I got that damn Exception error!
contactkarthi, Classpath is already set, that's how I get %JAVA_HOME%\bin javac to work in the first place....
I can bet you 1000 rupies that when I put that java file and that class file on a Unix/Linux system, it'd run smoothly without problem.
To top that, when I ran that code in in Eclipse ore NetBeans, it works!
@.@ <- me, dizzy
The only question remains is why doesn't it work?
Thanks guys, but ur suggestions were already attempted. (its not like I am haven exhausted my own mind before posting on here...)
Uros, that's how I got that damn Exception error!
contactkarthi, Classpath is already set, that's how I get %JAVA_HOME%\bin javac to work in the first place....
I can bet you 1000 rupies that when I put that java file and that class file on a Unix/Linux system, it'd run smoothly without problem.
To top that, when I ran that code in in Eclipse ore NetBeans, it works!
@.@ <- me, dizzy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
to run a class you need to add it to classpath, so as UrosVidojevic said, you can run it from an folder.
ASKER
Ok, I've tried it UrosVidojevic's command does work.
But then the question arose, Why doesn't this happen on my linux systems??
Also, I remember doing just simple java classname in cmd back when using 1.4.2_*
Is that one of the things that were changed from 1.4.2 to 1.5.0 ??
But then the question arose, Why doesn't this happen on my linux systems??
Also, I remember doing just simple java classname in cmd back when using 1.4.2_*
Is that one of the things that were changed from 1.4.2 to 1.5.0 ??
Just go to that folder (containing .class and .java file), run command prompt and enter:
java omega