[英]Netbeans Maven project: JAVA_HOME is not defined correctly
I have a NetBeans Platform project build with Maven2. 我有一个使用Maven2构建的NetBeans Platform项目。 When I try to create a new platform module I get this strange error:
当我尝试创建新的平台模块时,出现以下奇怪错误:
cd ~/src; JAVA_HOME=/usr/lib/jvm/jdk1.7.0/bin/java ~/netbeans-7.3/java/maven/bin/mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes...
Error: JAVA_HOME is not defined correctly.
We cannot execute /usr/lib/jvm/jdk1.7.0/bin/java/bin/java
In ~/.bashrc
I have definition of JAVA_HOME
: 在
~/.bashrc
我定义了JAVA_HOME
:
export JAVA_HOME="/usr/lib/jvm/jdk1.7.0"
export JDK_HOME="/usr/lib/jvm/jdk1.7.0"
There's no slash at the end, however maven appends /bin/java/bin/java
to this path. 最后没有斜杠,但是maven将
/bin/java/bin/java
附加到此路径。 I can build already existing module with Maven without problems, just when creating a new one it fails. 我可以使用Maven构建已经存在的模块而不会出现问题,只是在创建新模块时会失败。 Where does Maven get this
JAVA_HOME
? Maven从何处获得此
JAVA_HOME
?
EDIT: maven settings: 编辑: Maven设置:
$ mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.7.0_17
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.2.0-39-generic" arch: "amd64" Family: "unix"
You're redefining JAVA_HOME
on the command line to point to /usr/lib/jvm/jdk1.7.0/bin/java
, which is wrong: 您正在命令行上重新定义
JAVA_HOME
,使其指向/usr/lib/jvm/jdk1.7.0/bin/java
,这是错误的:
cd ~/src; JAVA_HOME=/usr/lib/jvm/jdk1.7.0/bin/java ...
Remove the JAVA_HOME=/usr/lib/jvm/jdk1.7.0/bin/java
from the command line: JAVA_HOME=/usr/lib/jvm/jdk1.7.0/bin/java
删除JAVA_HOME=/usr/lib/jvm/jdk1.7.0/bin/java
:
cd ~/src; ~/netbeans-7.3/java/maven/bin/mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes...
netbeans takes the JAVA_HOME from the definition of the Java Platform in the IDE (See Tools/Java Platforms) netbeans从IDE中Java平台的定义中获取JAVA_HOME(请参阅工具/ Java平台)
unless you select a custom platform, IDE uses the default one which is the one the IDE is running on. 除非选择自定义平台,否则IDE将使用默认平台,即运行IDE的默认平台。
All platforms need to be defined in the Tools/Java Platforms dialog and validation checks are in place to select the right folder. 需要在“工具/ Java平台”对话框中定义所有平台,并进行验证检查以选择正确的文件夹。
Maybe something changed in time for you and the definition there is not correct? 也许您的时间有所变化,并且定义不正确?
the problem was with incorrect definition of JAVA_HOME
in ~/.bash_profile
问题是
~/.bash_profile
的JAVA_HOME
定义不正确
NetBeans integration of maven prefers: NetBeans集成的maven首选:
System.getenv("JAVA_HOME")
before: 之前:
System.getProperty("java.home")
for linux find the mvn executalble file under netbeans's java/maven/bin folder and add 对于Linux,在netbeans的java / maven / bin文件夹下找到mvn executalble文件,然后添加
from="/bin/bin/java"
to="/bin/java"
JAVACMD="${JAVACMD/$from/$to}"
before the lines 上线之前
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly."
cheers 干杯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.