1

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 variable in /etc/profile.

Is it the recommended way?

Cœur
39k25 gold badges206 silver badges281 bronze badges
asked Jul 27, 2010 at 13:56

3 Answers 3

2

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.

answered Jul 27, 2010 at 14:19

Comments

1

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.

answered Jul 27, 2010 at 14:07

1 Comment

Ubuntu's one is outdated, not so good for performance. Btw, I heard about /etc/environment, anyone using it?
0

i always just set it in my .bashrc or .bash_profile...

answered Jul 27, 2010 at 14:16

2 Comments

this won't work as soon as you're trying to run some Java app from an init script during boot or as cron job (just to give two common examples).
or in /etc/profile like the OP did. faqs.org/docs/securing/chap6sec64.html

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.