I'm trying to compile and run some basic java programs using my
command line, rather than using Xcode. Its when I try and package
my program that I get compilation errors.
Note: I have all my .java files residing within a directory named
brainbox, and want to place the relevant class files inside a
directory named vzapusers.
This step works, and moves my class files to the correct directory.
Although, now I don't exactly know how to run the program?
I have been trying a variation of:
java Program1 // This gives me Exception in thread "main"
java.lang.NoClassDefFoundError
Perhaps its because I have packaged my program like so..
package games.programA;
Where have I gone wrong? and I don't really want to override my
default classpath. Is there a way that I could just manipulate the
JVM to allow me to run this file without
changing my environment variables?
One thing that would probably work is
java -cp ~/brainbox/myclassfiles/vzapusers games.programA.Program1
or
java -classpath ...
If you change the destination when you compile you quite probably
will need to be prepared to change the classpath when you run.
You _might_ not need to do this if you are compiling from the right
directory to begin with. In this case if pwd when you compile is ~/
brainbox/myclassfiles/vzapusers. Then, after you compile with the -d
that should contain games/ProgramA/Progam1.class and when you run
classpath would _have to_ include the parent directory of the games
directory (in other words, again, the -d directory).
This can all be done with command line args without a need to change
any environment variables.
Eventually you would probably want to get into jar'ing the class
files and then the jar file is what would have to be included in
classpath when you run.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden