File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Java command options Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java command options" Watch "Java command options" New topic

Java command options

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Up until now I have relied on my Java Editor (JCreator Pro) to handle my java compiling. I am now trying to learn how to do it all from the command line so that I will be able to work on any platform.
I know the basic command options for compiling and running a java program. However, the classpath option is confusing me a little.
I know that java -classpath path_to_extra.jar will compile my java file using path_to_extra.jar to search for external class libraries that I have included that are not part of the standard JDK.
Now, when I launch this application, and I use the -classpath with the java command, does it work the same? Do I even need to include it? Or does using this tag used with the JAVA command over-ride the compilers default package search?
Thanks for any help.

GenRocket - Experts at Building Test Data
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
I, too, have had difficulties navigating the nuances of classpath and sourcepath. This doesn't specifically answer your question, but it might be helpful.
I avoid the classpath issue entirely by dumping any extra jar files I need into the following folder: [JDK home]\JRE\lib\ext. By placing your jar files in that folder the compiler will recognize those files without you having to change your classpath setting.
I'm sure that I will eventually discover that there is a drawback to this technique, but it has helped me get around the classpath issue. If anyone thinks that this solution is terrible, please let me know.
[ April 09, 2002: Message edited by: Dave Winn ]

Fun programming etcetera!
I agree. Here's the link:
subject: Java command options
It's not a secret anymore!