最近开始学习用Linux做开发平台,在配环境的过程中,遇到了这个问题。
使用apt-get install后,环境自动被配置好了,但是我在找了/etc/profile和/etc/envir...都没有找到
现在要解决的问题是,我装了maven,但是在mvn -version时,会有一个警告说
没有配置JAVA_HOME,所以我想找找PATH的路径
(我可以单独配置JAVA_HOME)就是想了解一下apt-get到底会把PATH放到哪儿
echo $PATH 输出的结果没有JAVA的bin
我没表达清楚
想问的是,apt-get到底在哪儿配置PATH路径的
echo $PATH
where javac
which javac
Check the location
PATH and JAVA_HOME are two environment variables that have no relationship.
Deb-based Java is installed under /usr/lib/jvm/......
In the tutorials you found on the Internet about downloading Java from the official website and installing it manually, the reason why you need to adjust the PATH yourself is to allow java, javac and other programs to appear in the PATH so that they can be run directly under the command line. The Java on Oracle's official website is designed to be used in the same way by any distribution, so its executable program is placed in its own path and does not "pollute" the existing system path.
Java packaged by the distribution version itself will reorganize the path according to the distribution version's own specifications. For example, the Deb system uses the alternatives mechanism to establish symbolic links in the system path. Here is an example in Debian 7
So you don’t need to add /usr/lib/jvm/java-7-openjdk-amd64/jre/bin to PATH to run the java command. And you can install multiple Java versions simultaneously, use update-alternative --config java to switch the active version.
Of course, for software that relies on JAVA_HOME, JAVA_HOME still needs to be set. Basically, set it to /usr/lib/jvm/...
Does the configuration mentioned by the respondent refer to environment variables or the path to the installation file?
I think the problem description is a bit like the installation path of the file. You can use the following command:
If it is a variable, you can check /etc/profile or /etc/profile.d/*, /etc/bashrc, etc.