This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
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.