is there any shortcut to create classpath ?

when I run some application, it is required to add third-party jar file into classpath for javac, but I don't like to type so long file name. So I want to create a new folder under C:\, and hold all temp jar files inside the folder, and then I add this folder to system envoirment variable, ...

This is for windows operating system: u should keep all the jar files in one folder as u probably are.Then edit your autoexec.bat file which recides in c:.Set the classpath variable as follows: set classpath=%classpath%;c:\folderName\java40.jar;c:\folderName\jsdk.jar;c:\folderName\jweb.jar;c:\folderName\classes12.zip; Here folderName refers to the name of folder in which u r keeping ur .jar files. Then restart ur computer. Hopefully this will help u.

Edward Chen

Ranch Hand

Posts: 798

posted 13 years ago

Sorry, no, this is not what I want. It is me that mislead you guys.

It is not a classpath, similar to the class base directory, which hold all jar files. In the way above, I need type each jar file name into classpath, this way is time-wasted for me.

Edward, you could write a platform-specific script to add all JAR files in a specified directory to the CLASSPATH, or you could use a platform-independent scripting language such as Groovy to do the same. (At least I think you can do this with Groovy.)

Alternatively, I'd suggest taking a look at Ant, which has a feature to do what you're wanting to do that will work on any platform that Ant runs on. Plus, Ant does some other cool things.