Java Installation on Mac: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 4: Line 4:
* [[Mac#Subjects|Mac]]
* [[Mac#Subjects|Mac]]


 
=Overview=
 
!!!Java on Mac
 
 
!!!Internal
 
|[Mac]
 
!!!Overview


By default, no Javs is installed, when first attempting to use I get this:
By default, no Javs is installed, when first attempting to use I get this:


{{{
<pre>
NOMBP2:~ ovidiu$ java -version
NOMBP2:~ ovidiu$ java -version
No Java runtime present, requesting install.
No Java runtime present, requesting install.
}}}
</pre>


and a GUI window pops up: "to use the "java" command-line tool you need to install a JDK". More Info ... which says to go to the Oracle site.
and a GUI window pops up: "to use the "java" command-line tool you need to install a JDK". More Info ... which says to go to the Oracle site.


 
=Oracle SDK Installation=
!!!Oracle SDK Installation


Download the latest for Mac (jdk-8u25-macosx-x64.dmg or jdk-7u75-macosx-x64.dmg, depending of whether you need Java 8 or Java 7).
Download the latest for Mac (jdk-8u25-macosx-x64.dmg or jdk-7u75-macosx-x64.dmg, depending of whether you need Java 8 or Java 7).
Line 31: Line 21:
Double-click on DMG, then on PKG.
Double-click on DMG, then on PKG.


By default, it will install it in {{/usr/bin/java}}, which is a link to {{/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java}}
By default, it will install it in <tt>/usr/bin/java</tt>, which is a link to <tt>/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java</tt>.


The default JAVA_HOME is
The default <tt>JAVA_HOME</tt> is:


{{{
<pre>
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
}}}
</pre>


It can be obtained running
It can be obtained running


{{{
<pre>
/usr/libexec/java_home
/usr/libexec/java_home
}}}.
</pre>


!!!JAVA_HOME
=JAVA_HOME=


For a standard installation the value of <tt>JAVA_HOME</tt> is returned by the result of <tt>/usr/libexec/java_home</tt>:


For a standard installation the value of JAVA_HOME is returned by the result of /usr/libexec/java_home:
<pre>
 
{{{


export JAVA_HOME=$(/usr/libexec/java_home)
export JAVA_HOME=$(/usr/libexec/java_home)
Line 58: Line 47:
export PATH=${JAVA_HOME}/bin:${PATH}
export PATH=${JAVA_HOME}/bin:${PATH}


}}}
</pre>


/usr/libexec/java_home returns returns the path to a Java home directory from the current user's settings.
<tt>/usr/libexec/java_home</tt> returns returns the path to a Java home directory from the current user's settings.


In case multiple JDKs are installed, the java_line command line variables can be used to filter which JAVA_HOME is returned:
In case multiple JDKs are installed, the <tt>java_home</tt> command line variables can be used to filter which <tt>JAVA_HOME</tt> is returned:


-v filters on version
-v filters on version
Line 72: Line 61:
To see al JVMs installed:
To see al JVMs installed:


{{{
<pre>
/usr/libexec/java_home -V
/usr/libexec/java_home -V
}}}
</pre>
   
   
!!!Default Java 1.6 Location
=Default Java 1.6 Location=


{{{
<pre>
/Library/Java/Home/
/Library/Java/Home/
}}}
</pre>
 


If you want /usr/libexec/java_home to return the Java 6 home, run it with:
If you want /usr/libexec/java_home to return the Java 6 home, run it with:


{{{
<pre>
/usr/libexec/java_home -v 1.6
/usr/libexec/java_home -v 1.6
}}}
</pre>
 
__Referenced by:__\\
[{INSERT com.ecyrd.jspwiki.plugin.ReferringPagesPlugin WHERE max=20, maxwidth=50}]

Revision as of 19:08, 6 June 2016

Internal

Overview

By default, no Javs is installed, when first attempting to use I get this:

NOMBP2:~ ovidiu$ java -version
No Java runtime present, requesting install.

and a GUI window pops up: "to use the "java" command-line tool you need to install a JDK". More Info ... which says to go to the Oracle site.

Oracle SDK Installation

Download the latest for Mac (jdk-8u25-macosx-x64.dmg or jdk-7u75-macosx-x64.dmg, depending of whether you need Java 8 or Java 7).

Double-click on DMG, then on PKG.

By default, it will install it in /usr/bin/java, which is a link to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java.

The default JAVA_HOME is:

/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

It can be obtained running

/usr/libexec/java_home

JAVA_HOME

For a standard installation the value of JAVA_HOME is returned by the result of /usr/libexec/java_home:


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

...

export PATH=${JAVA_HOME}/bin:${PATH}

/usr/libexec/java_home returns returns the path to a Java home directory from the current user's settings.

In case multiple JDKs are installed, the java_home command line variables can be used to filter which JAVA_HOME is returned:

-v filters on version

-a filters on architecture

-d filters on data model.

To see al JVMs installed:

/usr/libexec/java_home -V

Default Java 1.6 Location

/Library/Java/Home/

If you want /usr/libexec/java_home to return the Java 6 home, run it with:

/usr/libexec/java_home -v 1.6