Mac OS X 10.6.7 Java Path Current JDK confusing

前端 未结 5 1254
臣服心动
臣服心动 2020-11-29 02:05

I have trouble understanding (actual paths vs links) for multiple java versions on my Mac OSX. Normally in windows if I have multiple versions installed in my machine, I can

相关标签:
5条回答
  • 2020-11-29 02:13

    Most possibly you only have one jdk installed, thus all the soft links points to the same jdk. If you however did have multiple jdks installed you would need to choose which one to use with the 'Java Preferences' app in your /Application/Utilities.

    Soft links are by the way created with the ln -s command from Terminal.

    0 讨论(0)
  • 2020-11-29 02:21

    set $JAVA_HOME=$(/usr/libexec/java_home) in your .bash_profile

    or export JAVA_HOME=$(/usr/libexec/java_home);

    echo $JAVA_HOME

    0 讨论(0)
  • 2020-11-29 02:25

    For different types of JDKs or installations, you will have different paths.

    On Mac OS X Mavericks, the path I found as following:

    1) Built-in JRE default:

     /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    

    2) JDKs downloaded from Apple:

     /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/
    

    3) JDKs downloaded from Oracle:

    /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
    
    0 讨论(0)
  • 2020-11-29 02:33

    From Apple Technical Q&A Java Questions:

    User Preferences

    On Mac OS X, the Java runtime provides the java.util.prefs API which is backed by the standard Mac OS X Preferences API and directories. Simply using this pure Java API reads and stores your application's preferences in ~/Library/Preferences in a Mac OS X property list file. For applications that may already have their own preferences format, these preferences should be stored in the ~/Library/Preferences directory as well. This directory can be reached from Java code by creating a file with the path of System.getProperty("user.home") + "/Library/Preferences/" + "com.example.your.Application". An application that should have global preferences across all users could instead reside in /Library/Preferences, however this directory is not writable by non-admin users.

    0 讨论(0)
  • 2020-11-29 02:35

    Just run following commands:

    $ brew update
    $ brew install jenv
    $ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bash_profile
    $ echo 'eval "$(jenv init -)"' >> ~/.bash_profile
    $ source ~/.bash_profile
    
    $ jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/
      oracle64-1.8.0.45 added
      1.8.0.45 added
      1.8 added
    
    $ jenv add /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
      oracle64-1.7.0.79 added
      1.7.0.79 added
      1.7 added
    
    $ jenv versions
    * system (set by /Users/wanluwang/.jenv/version)
      1.7
      1.7.0.79
      1.8
      1.8.0.45
      oracle64-1.7.0.79
      oracle64-1.8.0.45
    
    $ java -version
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
    
    $ jenv global oracle64-1.7.0.79
    
    $ java -version
      java version "1.7.0_79"
      Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
    
    0 讨论(0)
提交回复
热议问题