Official way to setup JAVA_HOME environment variable in Ubuntu server?
Assume I am compiling the JDK from source downloaded from Oracle.
Now the JDK is extracted into /opt/oracle/jdk/
I am exporting the JAVA_HOME and the path environment var开发者_如何学Ciable in /etc/profile.
Is it the recommended way?
I am exporting the JAVA_HOME and the path environment variable in /etc/profile.
That's one way to do it. But consider that different users (or different applications) on the machine may need to use different Java installations. So other options are for users to set the environment variables in their personal shell profiles, and for applications to set them in wrapper scripts, "init.d" scripts or whatever.
There is no single "right" way to do this. Pick a way that best fits your needs.
Thats fine to set JAVA_HOME, but there are a few other things you should also do.
You should also set it up as an alternative for java and javac and register it using the alternatives system.
Why are you compiling the JDK from source? Ubuntu does host Sun Java packages.
i always just set it in my .bashrc or .bash_profile...
精彩评论