〖linux〗 fast switching between multiple JDK versions

Source: Internet
Author: User
Tags java se

Because of the need for work, it is often necessary to switch to JDK versions like my home directory with three JDK versions:

~/apt/jdk1. 6 . 0_34 # JDK6~/apt/jdk1. 7 . 0_67 # JDK7~/apt/jdk1. 8. 0_05 # JDK8

such as compiling Android complete system source code, Google recommends the use of JDK6

In the implementation of the work, due to the actual needs of the project, to use JDK7 to implement some tools

To make it easier to switch JDK versions, I wrote a script:

1#!/bin/SH2 # Usage:. this_file [Argvs]3 4Jdk6_home=~/apt/jdk1.6. 0_345Jdk7_home=~/apt/jdk1.7. 0_676Jdk8_home=~/apt/jdk1.8. 0_057 8 # Default JDK69  Case$1 inchTen jdk6) OneExport Java_home=$jdk 6_home A         ;; - jdk7) -Export Java_home=$jdk 7_home the         ;; - jdk8) -Export Java_home=$jdk 8_home -         ;; +* ) -Export Java_home=$jdk 6_home +         ;; A Esac at  -Export path= $JAVA _home/bin: $JAVA _home/jre/Bin: $PATH -Export classpath= $CLASSPATH: $JAVA _home/lib: $JAVA _home/jre/lib

How to use:

For example, execute in the shell when you need to switch the JDK7 . [Script file name] Jdk7

Premise: Download and extract JDK7 to ~/apt/jdk1.7.0_67(modify according to your own needs)

JDK version download Link:

Java SE 1.1:http://www.oracle.com/technetwork/java/javasebusiness/downloads/ java-archive-downloads-javase11-419415.html
Java SE 1.2:http://www.oracle.com/technetwork/java/javasebusiness /downloads/java-archive-downloads-javase12-419414.html
Java SE 1.3:http://www.oracle.com/technetwork/java/ Javasebusiness/downloads/java-archive-downloads-javase13-419413.html
Java SE 1.4:http://www.oracle.com/ technetwork/java/javasebusiness/downloads/java-archive-downloads-javase14-419411.html
JDK5 Download:/http  Www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html
  JDK6 Download: http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html
JDK7 Download: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
JDK8 Download:/http www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.