Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm a newbie to Linux so please forgive me for asking such stupid question!

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

share|improve this question
1  
Possible duplicate of 18472 –  faif Sep 29 '11 at 9:31
1  
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

3 Answers 3

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.

Try

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

Example

rpm -ql jdk1.8.0_20 | grep "jdk1.8.0_20/bin$"
/usr/java/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.

JAVA_HOME='/usr/java/jdk1.8.0_20'
export JAVA_HOME
PATH="$JAVA_HOME/bin:$PATH"
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

 
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.