Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When installing packages on Ubuntu with the apt-get command, this will ensure that in the future, you can use a variable in the terminal, which will execute a binary file.

If you manually download the source, for instance of the Java JDK, this is not so.

I can't do javac
I have to do /usr/java/jdk1.6.0_21/bin/javac

My question is: is it enough simply to set an alias, or is there more that must be done?

share|improve this question
up vote 2 down vote accepted

Whether or not an alias is enough will depend a lot on the program in question and how you use it. If you are the only user on your machine using the program, and you always call it from an interactive console, and never use it inside scripts, then an alias might be sufficient (unless you notice things not working right).

But if you want to use the command in scripts, or even put launchers to it (in the GNOME menu or gnome-panel or in a dock, etc.), then it'll be more convenient to do something else.

Your other options are to 1) define a symbolic link, from, e.g., /usr/local/bin

cd /usr/local/bin
sudo ln -s /usr/java/jdk1.6.0_21/bin/javac javac

Then, javac should work.

Or 2), modify your $PATH environmental variable to include the directory in question, e.g., in your .bashrc or .profile, etc., put:

export PATH=$PATH:/usr/java/jdk1.6.0_21/bin

And then all the executables in that folder can be called directly.

share|improve this answer

update-java-alternatives is the tool to use to set the Java JVM to be used.

share|improve this answer

I don't know what setting an alias will do, but as an alternative, you can add the following line into your .bashrc

export PATH="$PATH:/usr/java/jdk1.6.0_21/bin/"
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .