Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I've installed jdk1.7.0.rpm package in RHEL6.
Where I do find the path to execute my first java program?

share|improve this question
Possible duplicate of 18472 – ierax Sep 29 '11 at 9:31
Hi, Mohammad. It's not a stupid question, but one that has been answered in several places already - like this or this question. – rozcietrzewiacz Sep 29 '11 at 9:40
Just an PS: on MacOS, Java is usually installed at '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home', where the version number could be different. – Daniel Wang Jan 19 '15 at 19:05

Try either of the two:

$ which java

$ whereis java

For your first java program read this tutorial:

"Hello World!" for Solaris OS and Linux

share|improve this answer

You can list the installed files with

rpm -ql packagename

You will see somewhere a bin directory with java executable

But if the JDK RPM was correctly installed you should already find java in you path.


javac MyFirstJavaClass.java

and if everything compiles

java MyFirstClass

(If you didn't change anything the current directory . should already be in your class path)

share|improve this answer

Since this question is RPM specific, rpm is the way to get started (as answered by @Matteo).

rpm flags

-q is short for --query
-l is short for --list


rpm -ql jdk1.8.0_20 | grep "jdk1.8.0_20/bin$"

Knowing this may be desirable for setting a user or application's $JAVA_HOME variable. This is often needed when a system has multiple versions of java installed, or multiple distributions of java installed, such as OpenJDK and Oracle/Sun.

$JAVA_HOME Example

In the ~/.bash_profile, or related file (.bashrc, .zshrc, .cshrc, setenv.sh), something similar to the below may be used.

export JAVA_HOME
export PATH

If you would like more control over where Java gets installed, such as in /opt, then the tarball can be used instead of the RPM file.

Other similar questions, are asking about how to find any binary or file, in the general case.

share|improve this answer

Your Answer


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.