In the run configuration of eclipse, you are provided with a set of default variables that you can use in the VM arguments, like container_path
and env_var
.
What I want to access is a classpath variable, M2_REPO
, but can't see a way of doing this. I need to specify a javaagent in the VM arguments, which requires a path to a jar file. This jar file lives in the maven repository, but I can't find a way of specifying the path to the maven repository using the already configured M2_REPO
Classpath variable (configured in windows
->preferences
->java
->Build Path
->Classpath variable
).
What I would like to do is use this as my VM arguments but can't because classpath_var
isn't a real variable.
-javaagent:${classpath_var:M2_REPO}/org/apache/openjpa/openjpa/2.1.0/openjpa-2.1.0.jar
Is there any other way of accessing the value of M2_REPO
in VM arguments?
In Eclipse, go to Window > Preferences > Java > Build Path > Classpath Variables. Click New, enter the following information and click OK.
If you're asking where Eclipse stores the values you put in the classpath preferences page, then it's under the . metadata directory, probably in the plugins/org. eclipse.
The CLASSPATH environment variable tells the Java Virtual Machine and other Java applications where to find the class libraries, including user-defined class libraries.
This isn't exactly what you asked for, but it worked for us as a way of sharing a codebase and not having hard coded paths in our run configurations. Rather than using a classpath variable, use a string substitution variable (configured in windows -> preferences -> run/debug -> String Substitution
). Set it to the same path as the value of M2_REPO and save. Using the above example if your string substitution variable name was also M2_REPO, the VM Argument would be
-javaagent:${M2_REPO}/org/apache/openjpa/openjpa/2.1.0/openjpa-2.1.0.jar
To be even more clear, I would personally just create an openjpa_2_1_0_agent string substitution variable that went directly to your open jpa 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