I'm just trying to get started with Java and have run into some difficulties already. I think the problem is that I haven't set the environment path correctly. When I attempt to run a short program(from the headfirst java book) I get the following error:
Welcome to Darwin! Max-Bejnamins-Computer:~ maxbenjamin$ java /Users/maxbenjamin/Desktop/BeerSong.class Exception in thread "main" java.lang.NoClassDefFoundError: /Users/maxbenjamin/Desktop/BeerSong/class
I tried to set the PATH variable by altering the /private/etc/profile to:
note that this assumes that you are using the default package (i.e. not "package" keyword at the beginnig of the .java file).
If you file were using the package "name.of.the.package" and were name "app.java", you would have to:
* put this line in the very beginning of the java file: package name.of.the.package
* create the directory /Users/maxbenjamin/Desktop/name/of/the/package * put the java file in /Users/maxbenjamin/Desktop/name/of/the/package * compile it * cd /Users/maxbenjamin/Desktop/ * execute : java name.of.the.package.app
It is a mistake to think you can solve any major problems just with potatoes.<br />--Douglas Adams