简体   繁体   English

Java构建路径中的Windows环境变量

[英]Windows environment variable in Java build path

How do I use a Windows environment variable to specify where a jar is located in an Eclipse project build path? 如何使用Windows环境变量来指定jar在Eclipse项目构建路径中的位置?

The JAVA_HOME environment variable for example could be in a different location on the server than on my PC, but if I have JAVA_HOME set as an environment variable on both machines, how can I specify in Eclipse to use a jar in the JAVA_HOME so it is the same on both machines? 例如,JAVA_HOME环境变量可以在服务器上与我的PC上不同的位置,但是如果我在两台机器上都将JAVA_HOME设置为环境变量,那么如何在Eclipse中指定在JAVA_HOME中使用jar?两台机器上都一样?

If your using Maven, just put an entry in your pom.xml like this: 如果您使用的是Maven,只需在pom.xml中输入以下内容:

<dependency>
    <artifactId>com.mysite</artifactId>
    <groupId>mylib</groupId>
    <version>${mylib.version}</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/mylib-1.0.0-SNAPSHOT.jar</systemPath>
</dependency>

This requires you install the Maven M2E plugin for Eclipse. 这需要您安装Eclipse的Maven M2E插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM