Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 helloworld.java
I have to do /usr/java/jdk1.6.0_21/bin/javac helloworld.java

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

share|improve this question

3 Answers 3

up vote 1 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 helloworld.java 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.