[java] i can compile JAVA, but cant run CLASSes!
i can compile java files and it generates class files.
but i cant run the classes.
c:\java_file_location\java HelloWorld
-----------
i reinstalled this JRE last night, jre-1_5_0_06-windows-i586-p-iftw.
when i try to run i get this error:
'Exception in thread "main" java.lang.NoClassDefFoundError: HelloJava1'
...and yes, this class does exist.
Quote:Original post by GekkoCube
c:\java_file_location\java HelloWorld
NoClassDefFoundError: HelloJava1'
A class called "HelloJava1" should be in a file called "HelloJava1.class".
A class called "HelloWorld" should be in a file called "HelloWorld.class".
You have seem to have intermixed class name and file name.
Is your class public? And does it have a public static main method?
sorry. the names are all correct.
im using a HelloWorld example that came with a text book on CD.
im using a HelloWorld example that came with a text book on CD.
here's a thought...
if i install the java SDK, in my case jdk1.5.0_06, do i need to install the jre (java runtime), which in my case i have jre1.5.0_06 ?
maybe this has somethign to do with it, although i cant see why this is the problem.
if i install the java SDK, in my case jdk1.5.0_06, do i need to install the jre (java runtime), which in my case i have jre1.5.0_06 ?
maybe this has somethign to do with it, although i cant see why this is the problem.
Can you post the entire code via copy and paste into this forum please?
And does this work:
java -cp . HelloWorld
?
And does this work:
java -cp . HelloWorld
?
Quote:Original post by GekkoCube
if i install the java SDK, in my case jdk1.5.0_06, do i need to install the jre (java runtime), which in my case i have jre1.5.0_06 ?
The SDK includes the JRE. There should be a JRE folder in the SDK folder.
Of course you cannot run .class files built by Java 1.5 with Java 1.4
Fred304
i dont know who you are, but you're a genius.
using java -cp . HelloWorld WORKS!
now allow me to research what the heck this means!
i dont know who you are, but you're a genius.
using java -cp . HelloWorld WORKS!
now allow me to research what the heck this means!
okay, i've no idea.
i know the -cp is for classpath.
but i never had to do this before.
and besides, the class exists in the same folder as the call to java.
so what gives?
also, when i exit the java app, the console gets stuck!
i know the -cp is for classpath.
but i never had to do this before.
and besides, the class exists in the same folder as the call to java.
so what gives?
also, when i exit the java app, the console gets stuck!
Check to see if the CLASSPATH environment variable is set. If it is, then that could cause the problem. Don't set the CLASSPATH environment variable globally.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement