I have to compile a java file using builtin struts classes. so I used the javac -classpath option. is there any other do-it-once and use javac without -classpath option. is there a way to tell the compiler to find those classes in struts-core.jar jar file without using -classpath, like say, add the jar file to where bootstrap or extension class files reside. by doing so we can avoid -classpath option.
have a great day,
posted 9 years ago
If you don't specify a -classpath parameter, javac uses the system environment variable classpath. If you set this environment variable with the path you want to use for compiling, you can omit the -classpath parameter with javac.
It is important to understand, though, that this affects the compile-time classpath only. The run-time classpath is determined by your application server, and in most cases they completely ignore the classpath environment variable and set up their own classpaths according to the rules the J2EE spec and their own rules.
If you're really serious about developing Java web applications, I'd consider doing your compiles with ant scripts or using an IDE. I don't know a single professional Java developer that uses javac for compiles any more.