Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes using the �classpath option in the javac command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using the �classpath option in the javac command" Watch "using the �classpath option in the javac command" New topic
Author

using the �classpath option in the javac command

Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
I�m trying to use the �classpath option in the javac command from the command line in windows. My problem is when the path has spaces in it. How do I get to a directory such as the following: �javac �classpath C:/Program Files/Apache Software Foundation/Tomcat 5.0�?

Thanks
Amit Saini
Ranch Hand

Joined: Oct 20, 2004
Posts: 280
Use double quotes. C:\"Documents and Settings" etc
On a Windows CMD prompt you could just use the TAB key as well.

eg. c:\do <press tab> and the entire path is printed automatically.

Hope this helps.
Amit
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
The first level of the path is printed within quotes with this method. Then you have to type the rest.

Another way to do it is to use Windows Explorer to navigate to the path you want to get your classes from, copy the path from the address bar, then paste it into a command line in a batch file. Now you have the batch file that you can run any time you need. If you need to make modifications, say to the class path, you can copy the line in the batch file, remark the original out so that you still have it if you ever need it, then run the batch file from the command prompt or by double-clicking it in Windows.
[ October 20, 2004: Message edited by: Jeff Bosch ]

Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
Got it, thanks. I used the quotes method and it worked like a charm.

I'm not quit sure how to use the batch file method, but I'm going to give it a try and see what happens.
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Quick steps:

1. Create a new text file in Notepad.

2. Add the javac line, just like you would in your dos session.

3. Save the file as something like "CompileJava.bat".

You can now run the batch file from the dos prompt or double-click it in Windows. There's no advantage to doing this for only one compilation, but how many programs have you worked on that only required compilation once? By doing it this way, you don't have to reopen a dos session or re-type the command. I use this method for compilation and also for running a Java app under a JVM of my choice.

You can also have multiple compilation configurations in the batch file, one for each line, then add "REM" in front of the ones you don't use. This is the same as commenting out a line of code in a source file. To modify your compilation configuration, you just move one of the REMarks from the line you want to run to the currently unREMarked line. You can also copy, paste, then modify any line. Very flexible, very repeatable.
[ October 20, 2004: Message edited by: Jeff Bosch ]
Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
Jeff, you rock.
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Du-u-de!

(Translation: Thank you!)
[ October 20, 2004: Message edited by: Jeff Bosch ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using the �classpath option in the javac command
 
Similar Threads
Although activation.jar,mail.jar are in the same folder I get in compile(well?)
Newbie question
which jar file for classpath ?
*.jar
cannot find symbol : class HttpServletResquest