简体   繁体   English

设置默认的Java编译器

[英]Setting the default java compiler

I have openjdk 1.8 installed via yum in '/usr/bin/java' and I have also downloaded the Oracle Java Hotspot 1.7 compiler in /opt/devel/jdk_1.7' I updated my PATH in my ~/.bashrc file to include /opt/dvel/jdk_1.7/bin' 我已经通过yum在'/ usr / bin / java'中安装了openjdk 1.8,并且还在/opt/devel/jdk_1.7' I updated my PATH in my ~/.bashrc file to include下载了Oracle Java Hotspot 1.7编译器, /opt/devel/jdk_1.7' I updated my PATH in my ~/.bashrc file to include /opt/dvel/jdk_1.7/bin'

When I run which java the terminal only responds with '/usr/bin/java' 当我运行which java ,终端仅以“ / usr / bin / java”响应

  1. Why is the other java compiler in '/opt/devel/jdk_1.7/bin' not being found? 为什么找不到“ /opt/devel/jdk_1.7/bin”中的其他Java编译器?
  2. How can I make this other compiler be the default compiler when executing java? 执行Java时,如何使其他编译器成为默认编译器?

I would set JAVA_HOME too in ~/.bashrc 我也会在〜/ .bashrc中设置JAVA_HOME

Setting JAVA_HOME 设置JAVA_HOME

jdk7oracle=/opt/devel/jdk_1.7 
export JAVA_HOME=$jdk7oracle export
PATH=$JAVA_HOME/bin:$PATH

and then test using 然后使用

java -version

Also make sure you start a new terminal session so that bashrc is reloaded after your edits. 另外,请确保您启动了一个新的终端会话,以便在编辑后重新加载bashrc。 OR you can source the bashrc file if you don't want to restart terminal. 或者,如果您不想重新启动终端,则可以获取bashrc文件。

source ~/.bashrc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM