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,

Regards,
prem

Recommended Answers

All 4 Replies

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

javac: Command not found - after installing Java

If you receive this error, UNIX cannot find the compiler, javac.
or
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>

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.