Jump to content

I have some java problems


space
 Share

3 posts in this topic

Recommended Posts

Hi,

 

I´m trying to run a Hello World app just to check if the java enviroment is OK.

 

I´m getting an error:

$ java HelloWorldApp.java

Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp/java

 

I have tried different classpaths and javahomes, and searched google for info but haven´t come any further...

 

What is it supposed to be?

Now I have them set like this:

 

$ echo $JAVAHOME

/Library/Java/Home/

 

$ echo $JAVA_HOME

/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/

 

$ echo $CLASSPATH

/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/:/Library/Java/Extensions/:./

 

 

Thankful for any hints!

Link to comment
Share on other sites

  • 2 weeks later...

To elaborate: you need to compile the .java file, which produces a new file. You then run that new file. javac is the java compiler, so you use the javac command first, then use java to run your compiled code. This is different from some other languages, which are interpreted (on the fly), like Perl and PHP scripts, Matlab .m files, HTML pages, etc. But for most heavy duty languages (like C and Java), you need to first compile your code, which means it doesn't need to be interpreted from high-level arguments into low-level arguments each time you run it. It's faster that way.

Link to comment
Share on other sites

 Share

×
×
  • Create New...