| CARVIEW |
|
parse-dot-classpath
|
| Summary | Set CLASSPATH env var from Eclipse .classpath files |
|---|---|
| Categories | None |
| License | Berkeley Software Distribution (BSD) License |
| Owner(s) | kohsuke |
Message from the owner(s)
Even with Eclipse, it is often convenient to have a shell (or a command prompt) so that you can launch your program with various parameters. However, to do that, you have to set the CLASSPATH variable correctly, I used to do this by writing a little shell script, but then you have to maintain it as you add/remove libraries. All of those adds up to a lot of efforts.
This little tool makes this process painless by:
- reading Eclipse's .classpath file (which contains paths to all the important directories/jar files)
- formatting the contents into ';' or ':' separeted CLASSPATH variable style, and then
- printing that out to stdout.
On Windows
You can then write a little batch file to set the output to the variable.
for /f "tokens=*" %%i in ('java -jar parse-dot-classpath.jar "%*"') do set CLASSPATH=%%i
With this, I only need to type "parse-dot-classpath" in the directory that contains .classpath and it sets the CLASSPATH variable correctly. (Thanks to Dwight Morr for this tip)
On Unix
You can then write a little wrapper script to set the output to the variable. This last step usually depends on your environment and shell, but I have the following shell script:
#!/usr/bin/bash export CLASSPATH="$(java -jar parse-dot-classpath.jar "$@" )"
And the following alias:
alias parse-dot-classpath=". ~/bin/parse-dot-classpath"
With these, I only need to type "parse-dot-classpath" in the directory that contains .classpath and it sets the CLASSPATH variable correctly.
A similar approach would work for all Unix flavors including cygwin.
Download
Download the library from here.
Usage
When invoked without any argument, it assumes that a .classpath file is in the current directory.
If arguments are specified, they will be treated as directory names that contain .classpath, or files that follow that format of the .classpath file. When multiple arguments are specified, they are combined to form one CLASSPATH. This is useful when one project depends on another project, as .classpath doesn't tell you where the depended projects physically reside.
| Powered by CollabNet | Feedback |
FAQ |
Press |
Developer tools
© 1995 - 2007 CollabNet. CollabNet is a registered trademark of CollabNet, Inc. |
