DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • How To Get and Set PDF Form Fields in Java
  • Micro Frontends for Quarkus Microservices
  • Building AI Applications With Java and Gradle
  • Demystifying Project Loom: A Guide to Lightweight Threads in Java

Trending

  • Auto-Scaling DynamoDB Streams Applications on Kubernetes
  • Chronicle Services: Low Latency Java Microservices Without Pain
  • Performance Optimization Strategies in Highly Scalable Systems
  • Cognitive AI: The Road To AI That Thinks Like a Human Being
  1. DZone
  2. Coding
  3. Java
  4. Multiple Versions of Java on OS X Mavericks

Multiple Versions of Java on OS X Mavericks

Manipulate Java 7 and 8 from Oracle on OS X Mavericks.

Cristian Chiovari user avatar by
Cristian Chiovari
·
Apr. 21, 14 · Tutorial
Like (0)
Save
Tweet
Share
46.78K Views

Join the DZone community and get the full member experience.

Join For Free

Of course after OS X Mountain Lion it was the time to update my java on OS X Mavericks.

Let’s see how to use multiple versions of java on OS X Mavericks.

I plan to use  Java7 and Java 8 from Oracle and to have an easy way of changing the default version.

As you probably know there is a difference between JRE and JDK.If not a very nice response you can find here.

Regarding JRE we should keep in mind that

1) “Only one JRE can be installed at a time. The system will not install a JRE that has a lower version than the current version. If you wish to install a lower version of the JRE, first uninstall the current version.”

2)”Installing a JRE from Oracle will not update java -version symlinks or add java to your path. To be able to do this, you need to install the JDK.”

I installed JdK 7 and Jdk 8

Right after I installed Jdk8 it seems that the simlinks were updated and java -version returned

MacCris:~ cristianchiovari$ java -version
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b05, mixed mode)
MacCris:~ cristianchiovari$

as well java_home was set to Jdk 8

MacCris:~ cristianchiovari$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home

In my .profile i have as well defined

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

As well i found very practical this command which is used to choose the default java_home. (it seems it iterates all java installations and the latest version is tool)

MacCris:~ cristianchiovari$ /usr/libexec/java_home -verbose
Matching Java Virtual Machines (7):
1.8.0_20, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
1.7.0_45, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
1.7.0_11, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home
1.7.0_10, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home
1.7.0_05, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
1.6.0_65-b14-462, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_65-b14-462, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Now in order to have latest Jdk7 installed on my computer as default java I had to change in my .profile file

#export JAVA_HOME=$(/usr/libexec/java_home)
export JAVA_HOME="`/usr/libexec/java_home -v '1.7*'`"

After opening a new terminal

MacCris:~ cristianchiovari$ java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

Still

MacCris:~ cristianchiovari$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home

That however is not affecting the default java version as described above.
In order to change that you might need to uninstall the Jdk that points to or to use some kind of hacked
as in http://stackoverflow.com/questions/17885494/how-can-i-change-mac-oss-default-java-vm-returned-from-usr-libexec-java-home

Inspired from :

http://docs.oracle.com/javase/7/docs/webnotes/install/index.html

https://developer.apple.com/library/mac/qa/qa1170/_index.html

http://stackoverflow.com/questions/15826202/where-is-java-7-installed-on-mac-os-x

http://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html

Java (programming language)

Published at DZone with permission of Cristian Chiovari, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How To Get and Set PDF Form Fields in Java
  • Micro Frontends for Quarkus Microservices
  • Building AI Applications With Java and Gradle
  • Demystifying Project Loom: A Guide to Lightweight Threads in Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: