In our project we use Eclipse launch configurations which are under version control to be shared with all developers. Now it is necessary to include an external archive to a launch configuration file's classpath. Fortunately the required archive is in every developer's local Maven repository.
I already found out that there is a classpath variable called M2_REPO which references to the local Maven repository (being valid for any developer).
But how to use this variable in the following classpath definition to replace the absolute path?
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
...
<listEntry value="<?xml version="1.0" encoding="UTF-8"?><runtimeClasspathEntry externalArchive="C:/Dokumente und Einstellungen/050967/.m2/repository/com/google/gwt/gwt-dev/2.0.3/gwt-dev-2.0.3.jar" path="3" type="2"/>"/>
...
</listAttribute>
Or is there a way to include an environment variable (e.g. Windows' %USERPROFILE%
could help)?
The CLASSPATH environment variable tells the Java Virtual Machine and other Java applications where to find the class libraries, including user-defined class libraries.
Classpath is an environment variable that is used by the application ClassLoader or system to locate and load the compiled Java bytecodes stored in the . class file. To set CLASSPATH. the CLASSPATH can be overridden by adding classpath in the manifest file and by using a command like set -classpath.
Edit your launch configuration. Go to the "classpath" tab. Focus on "User Entries". Click the "Advanced" button.
M2_REPO
and click the "Extend" button. Select your JAR file.${env_var:your-environment-variable-name}/path-to-jar
. For example, if your system environment variable is MYVAR
and the JAR file is under subdir/myfile.jar
, you should type ${env_var:MYVAR}/subdir/myfile.jar
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With