多个jdk版本怎么使用指定的jdk去跑java程序?

两个版本的jdk:
命令:/usr/bin/java -version
openjdk version “1.8.0_332”
OpenJDK Runtime Environment (build 1.8.0_332-b09)
OpenJDK 64-Bit Server VM (build 25.332-b09, mixed mode)
命令: /opt/alibaba/java-1.8.0-alibaba-dragonwell-8.8.8.302.b1-1.al8/bin/java -version
openjdk version “1.8.0_302”
OpenJDK Runtime Environment (Alibaba Dragonwell 8.8.8-b01) (build 1.8.0_302-b1)
OpenJDK 64-Bit Server VM (Alibaba Dragonwell 8.8.8-b01) (build 25.302-b1, mixed mode)
创建java程序(hello.java):
import java.io.*;
public class hello
{
public static void main(String[] args){
System.out.println(“hello world!”);
}
}
运行java程序:
命令:/opt/alibaba/java-1.8.0-alibaba-dragonwell-8.8.8.302.b1-1.al8/bin/javac hello.java
(多了hello.class)
命令: /opt/alibaba/java-1.8.0-alibaba-dragonwell-8.8.8.302.b1-1.al8/bin/java hello
hello world!

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐