Setting PATH system variable

Asked by javarunner

I have installed the Sun Java SDK in usr/local/Java/jdk1.5.0_09 directory. I need to set the system PATH so that I can execute the java and javac commands from anywhere in my environment. I've tried the export command, but it did not seem to have the desired affect.
How can I do this?
Thanks...

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Kurt von Finck (mneptok) said :
#1

Put this in .bashrc or whatever file(s) your shell uses for environment variables:

PATH=${PATH}:/usr/local/Java/jdk1.5.0_09
export PATH

This will append your PATH to include Java, so do not overwrite prior PATH statements with this.

Revision history for this message
Eamonn Sullivan (eamonn-sullivan) said :
#2

This doesn't directly answer your question, but FYI that Java and the JDK are in the Ubuntu repositories already. Just do:

sudo apt-get install sun-java5-jdk sun-java5-jre sun-java5-plugin

Now run:

sudo update-alternatives --config java

And make sure you're using Sun's java. That'll handle all the path-setting for every user and makes it much easier to manage updates, etc. You'll have to enable the `multiverse' repository, I believe.

Hope that helps.

Revision history for this message
javarunner (randomnoise) said :
#3

Thanks for responding. The magic of sudo!
I'm just starting to get into Linux and have tried several distros.
I've used Windows since MS released version 1. Since I use so much
open-source in my work, I thought I'd give Linux a try as a dev
environment. Looked at several distros, Mandriva, xandros but finally
settled on Ubuntu. I have it as the only OS on this desktop, and have
it in a dual-boot setup on my laptop (with Win XP Pro). I'm trying to
transfer all development to Ubuntu - write-once, run-anywhere. I'll let
you know how it goes. I work with Java/JBoss/XFire/Axis stacks.
On Sun, 2006-10-01 at 06:22 +0000, Eamonn Sullivan wrote:
> Support request #1931 on Ubuntu changed:
> https://launchpad.net/distros/ubuntu/+ticket/1931
>
> Comment:
> This doesn't directly answer your question, but FYI that Java and the JDK are in the Ubuntu repositories already. Just do:
>
> sudo apt-get install sun-java5-jdk sun-java5-jre sun-java5-plugin
>
> Now run:
>
> sudo update-alternatives --config java
>
> And make sure you're using Sun's java. That'll handle all the path-setting for every user and makes it much easier to manage updates, etc. You'll have to enable the `multiverse' repository, I believe.
>
> Hope that helps.

Revision history for this message
Eamonn Sullivan (eamonn-sullivan) said :
#4

thanks for the reply. If this problem is solved, consider changing the status to "answered."

Can you help with this problem?

Provide an answer of your own, or ask javarunner for more information if necessary.

To post a message you must log in.