Dear all,
I am using linux fedora os. But i cannot able to set the java Classpath command.

Step 1:
whereis java
java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java /usr/share/man/man1/java.1.gz

Step 2:
vi .bash_profile
export JAVA_HOME=/usr/bin/java
export PATH=$PATH:/usr/bin/java

Step 3:
java -version
java version "1.6.0"
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK Server VM (build 1.6.0-b09, mixed mode)

Still i cannot able to compile and run the java programs.
Is there any other possibities i have missed in my machine.

Thank you,


5 Years
Discussion Span
Last Post by sepp2k

On Windows you don't need to set the classpath variable. In fact sometimes there is a problem if you don't set it correctly. Often it is better to pass the classpath to the java command on the commandline with the -cp option.


Step 2:
vi .bash_profile
export JAVA_HOME=/usr/bin/java
export PATH=$PATH:/usr/bin/java

export JAVA_HOME=/usr/lib/java
export PATH=$JAVA_HOME/bin:$PATH

BTW are you sure about that java directory, don't know how fedora but ubuntu comes with version number

Edited by peter_budo: n/a


javac: Command not found - after installing Java

If you receive this error, UNIX cannot find the compiler, javac.
javac: Command not found - after installing Java

Here's one way to tell UNIX where to find javac. Suppose you installed the JDK in /usr/local/jdk1.8.0. At the prompt you would type the following command and press Return:

/usr/local/jdk1.8.0/javac hello.java
Note: If you choose this option, each time you compile or run a program, you'll have to precede your javac and java commands with /usr/local/jdk1.8.0/. To avoid this extra typing, you could add this information to your PATH variable. The steps for doing so will vary depending on which shell you are currently running.

Class names, 'hello', are only accepted if annotation processing is explicitly requested

If you receive this error, you forgot to include the .java suffix when compiling the program. Remember, the command is javac hello.java not javac hello.

For more details, consult this lecture "Creating a Hello World application" in this page. <URL SNIPPED>

Edited by peter_budo: Keep it spam free, please read forum rules


javac command not found in linux fedora

Have you installed the JDK?

vi .bash_profile
export JAVA_HOME=/usr/bin/java

JAVA_HOME should be a directory, not an executable, and you shouldn't have to set it yourself.

export PATH=$PATH:/usr/bin/java

Again PATH should contain directories, not executables, and /usr/bin is already in the PATH (otherwise you wouldn't be able to run java -version), so there's no need for you to adjust the PATH.

Edit: Sorry, I did not realize that this post was three years old when I posted.

Edited by sepp2k

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.