将我的Mac更新到最新的Java JDK

时间:2015-10-11 07:31:09

标签: java ant

[2015-10-12 12:51]

  

...运行

little-mbook1:platform mlittle$ ant clean all
     Error: JAVA_HOME is not defined correctly.
       We cannot execute   /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home//bin/java
  

跑步......

mlittle-mbook1:bin mlittle$ export   JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
  

我将java_home设置为:   JAVA_HOME = /库/爪哇/ JavaVirtualMachines / jdk1.8.0_60.jdk /内容/首页

     

我刚刚注意到Apache Ant正在寻找错误的路径,还有一个额外的'/'

     

根据您的电子邮件

     

“Ant将尝试使用$ JAVA_HOME / bin / java文件。如果不存在,那么> JAVA_HOME不正确,就这么简单。例如,如果你的java可执行文件>在/ path / to / whatever / bin / java,然后JAVA_HOME应该是/ path / to / whatever。“

     

...或       $ JAVA_HOME / bin中/ JAVA

     

但是错误消息表明它正在寻找路径..

$JAVA_HOME//bin/java
  

注意'//'而不是'/':如何纠正?

     

或者是否有'ant'命令,我可以强制它查看正确的路径?

=================

[2015-10-12:1204]

  

谢谢,你已经为我解决了一个问题,我明白/ java是$ java_home / bin / java路径中的可执行文件,而不是文件夹   至于$ JAVA_HOME / bin / java -version,   我得到了以下内容......

mlittle-mbook1:~ mlittle$ /usr/libexec/java_home -v
java_home: option requires an argument -- v
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
mlittle-mbook1:~ mlittle$ which java
/usr/bin/java
  

现在重新运行ant以尝试构建hybris实例......

mlittle-mbook1:~ mlittle$ cd 00hybris/hybris/bin/platform
mlittle-mbook1:platform mlittle$ pwd
/Users/mlittle/00hybris/hybris/bin/platform
mlittle-mbook1:platform mlittle$ . ./setantenv.sh
mlittle-mbook1:platform mlittle$ ant clean all
Error: JAVA_HOME is not defined correctly.
We cannot execute   /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home//bin/java
  

正如您所看到的,我仍然遇到过“蚂蚁”问题。尽管现在看起来正确的$ java_home位置。

=======

=======

[2015-10-11-23:20] 进一步调查

mlittle-mbook1:Users mlittle$ cd   
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

mlittle-mbook1:Home mlittle$ pwd
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

mlittle-mbook1:Home mlittle$ ls -a
.                   README.html             db                  lib
..                  THIRDPARTYLICENSEREADME-JAVAFX.txt  include         man
COPYRIGHT               THIRDPARTYLICENSEREADME.txt     javafx-src.zip release
LICENSE                 bin                 jre                 src.zip

mlittle-mbook1:Home mlittle$ cd bin

mlittle-mbook1:bin mlittle$ ls -a
.       jar     javafxpackager  jconsole    jjs     jsadebugd   keytool rmic servertool xjc
 ..     jarsigner   javah       jdb     jmap        jstack      native2ascii    rmid        tnameserv
appletviewer    java        javap       jdeps       jmc     jstat       orbd        rmiregistry unpack200
extcheck    javac       javapackager    jhat        jps     jstatd      pack200     schemagen   wsgen
idlj        javadoc     jcmd        jinfo       jrunscript  jvisualvm   policytool  serialver   wsimport

mlittle-mbook1:bin mlittle$ which java
/usr/bin/java
mlittle-mbook1:bin mlittle$ export    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
mlittle-mbook1:bin mlittle$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
mlittle-mbook1:bin mlittle$ 

====

 mlittle-mbook1:platform mlittle$ ant clean all
 Error: JAVA_HOME is not defined correctly.
   We cannot execute   /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home//bin/java
mlittle-mbook1:platform mlittle$* 

== 初步调查

我的MacBook上的Java安装似乎有问题,因为这与基于java的电子商务平台[Difficulties with installation script for hybris 5.6.02]的安装以及Apache Ant的使用有关......

  1. 关于我的MacBook .. 系统软件概述:
  2.   

    系统版本:OS X 10.10.5(14F27)
      内核版本:达尔文14.5.0
      启动音量:Macintosh HD
      启动模式:正常
      计算机名称:mlittle-mbook1
      用户名:mlittle-mbook1(mlittle)
      安全虚拟内存:已启用
      启动时间:1天5:34

    ======

    1。检查了哪个java ...

    mlittle-mbook1:~ mlittle$ which java
    /usr/bin/java
    

    2。重新检查哪个Java ..

    mlittle-mbook1:~ mlittle$ ls -l `which java`
    lrwxr-xr-x  1 root  wheel  74  5 Nov  2014 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
    

    第3。然后我在路径中下载了JDK版本8,更新60,等等:

    /库/爪哇/爪哇?JavaVirtualMachines

    以前它有.. ..

      

    /jdk1.7.0_21.jdk

    现在有了

      

    /jdk1.7.0_21.jdk
      /jdk1.8.0_60.jdk

    这令人困惑,我原以为它会取代/jdk1.7.0_21.jdk  使用/jdk1.8.0_60.jdk

    4。我检查了java的版本..

    mlittle-mbook1:~ mlittle$ java -version
    java version "1.7.0_21"
    mlittle-mbook1:~ mlittle$ java -version
    java version "1.7.0_21"
    Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
    

    它仍然表示java版本“1.7.0_21" ???

    所以我将/jdk1.7.0_21.jdk重命名为/old-jdk1.7.0_21.jdk

    4。我再次检查java的版本,然后我得到了......

    mlittle-mbook1:~ mlittle$ java -version
    java version "1.8.0_60"
    Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
    Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
    

    5。哪个应该是Hybris5.6.0.2的Java的正确版本[这是我试图安装的基于java的电子商务平台]通过设置ANT环境变量,并开始构建过程[ant clean all] ...但是...

    mlittle-mbook1:platform mlittle$ . ./setantenv.sh
    

    试图蚂蚁清理所有..并得到一个与JAVA_HOME有关的错误信息

    mlittle-mbook1:platform mlittle$ ant clean all
    Error: JAVA_HOME is not defined correctly.
      We cannot execute /Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home//bin/java
    

    6。再次检查java路径......

    mlittle-mbook1:platform mlittle$ which java
    /usr/bin/java
    

    7。我尝试更改Java_home路径,然后重新运行ANT。

    mlittle-mbook1:platform mlittle$ export JAVA_HOME=/Library/Java/Home
    mlittle-mbook1:platform mlittle$ ant clean all
    Error: JAVA_HOME is not defined correctly.
      We cannot execute /Library/Java/Home/bin/java
    

    8。再次检查“哪个Java”

    mlittle-mbook1:platform mlittle$ which java
    /usr/bin/java
    mlittle-mbook1:platform mlittle$ $JAVA_HOME/bin/java -version
    -bash: /Library/Java/Home/bin/java: No such file or directory
    

    9.我试图更改Java_home,重新启用Ant,但仍然收到错误消息..

    mlittle-mbook1:platform mlittle$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/
    mlittle-mbook1:platform mlittle$ ant clean all
    Error: JAVA_HOME is not defined correctly.
      We cannot execute /Library/Java/JavaVirtualMachines//bin/java
    

    10。 9.我试图更改Java_home,重命令Ant,但仍然收到错误信息..

    mlittle-mbook1:platform mlittle$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin
    mlittle-mbook1:platform mlittle$ ant clean all
    Error: JAVA_HOME is not defined correctly.
      We cannot execute /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/bin/bin/java
    

    11。再次检查哪个java

    mlittle-mbook1:platform mlittle$ which java
    /usr/bin/java
    

    我很困惑,显然我没有正确设置我的java设置主变量:有什么建议吗?

1 个答案:

答案 0 :(得分:3)

看起来这应该是正确的:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

Ant将尝试使用文件$JAVA_HOME/bin/java。如果这不存在,则JAVA_HOME不正确,就这么简单。 例如,如果您的java可执行文件位于/path/to/whatever/bin/java,则JAVA_HOME应为/path/to/whatever