Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-12-2004, 01:57 AM   #1
LQ Newbie
Registered: Nov 2004
Posts: 7

Rep: Reputation: 0
bash: javac: command not found???

I'm new to linux but I use linux a little at school and by connecting through a shell at home. Anyways, I just installed linux a little while ago and I opened a shell and tried to compile some java code by going to the directory of the code and typing "javac" like I do at school but it says the command is not found.

I previously had installed the java runtime environment and I just went to go and try to install the java development kit but it says it was already installed.

Is there some sort of path I need to set for the shell to look for the java compiler? Thanks in advance.

I have added aliases to my .cshrc file at school and I just found a bashrc file and csh.cshrc file in the /etc folder. Sorry, I'm really new to all of this. Anyways, I'm geussing I have to edit the bash file? Can anyone point me to a good tutorial of scripting for these files???

Last edited by MRAB54; 11-12-2004 at 02:18 AM.
Old 11-12-2004, 02:10 AM   #2
Registered: Aug 2004
Location: Northbrook, Illinois
Distribution: CentOS-5
Posts: 311

Rep: Reputation: 30
#locate javac
execute javac by typing in the full path to it such as if its in /usr/local


optionally add it to your search path. Most likely you can copy or link the binary javac to someplace like /usr/bin or /usr/local/bin and it will be in your path for future use.


Last edited by linux_terror; 11-12-2004 at 02:14 AM.
Old 11-12-2004, 03:09 AM   #3
Senior Member
Registered: Nov 2003
Location: Perth, Western Australia
Distribution: Ubuntu, Debian, Various using VMWare
Posts: 2,088

Rep: Reputation: 62
Edit ~/.bash_profile or ~/.bashrc or ~/.profile (I use .bash_profile).

Add the following lines to whichever file:

export PATH
export JAVA_HOME
where /path/to/java is wherever you installed it (Such as /usr/local/java)

I am not sure, but you may need to set the CLASSPATH as well in order to compilte a java program. This will be /path/to/java/lib. (With the same syntax as above)

When you have added the above lines to .bash_profile, enter the command:
source .bash_profile
Now you should be able to compile your program using javac.

I hope this helps

Last edited by IBall; 11-12-2004 at 09:30 PM.
Old 11-12-2004, 04:23 AM   #4
LQ Newbie
Registered: Nov 2004
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks for the fast reply, I edited the bashrc file like you said, I am not finding a .bash_profile file, and when I ran source bashrc, it says

bash: PATH: command not found
bash: JAVA_HOME: command not found
bash: CLASSPATH: command not found
bash: TMOUT: readonly variable

Old 11-12-2004, 04:42 PM   #5
Registered: Oct 2004
Distribution: Slackware
Posts: 376

Rep: Reputation: 31
Don't put spaces around the equals sign. Like:


export PATH
export JAVA_HOME
Old 04-03-2005, 08:37 PM   #6
Grim Notepad
LQ Newbie
Registered: Apr 2005
Location: Ontario, Canada
Distribution: RedHat 9
Posts: 2

Rep: Reputation: 0
I am recieving the same error with the "java command not being found" and "You need to install a VM before ...etc", i can get it to work if i source the ~/.cshrc before trying to run the program, is there any way of making it so that it always works?
Old 02-18-2015, 09:18 AM   #7
LQ Newbie
Registered: Feb 2015
Posts: 2

Rep: Reputation: Disabled
Thumbs up 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:

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 not javac hello.

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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash: command not found intels_ss Linux - Newbie 5 07-20-2005 08:41 PM
-bash: cp: command not found johnlittlepeap Fedora 2 11-15-2004 09:52 AM
-bash-- javac command not found nedian123 Programming 1 06-28-2004 05:16 PM
bash: command not found jc80 Fedora 3 03-14-2004 04:11 PM
J2sdk problem Javac command not found CollestonPie13 Linux - Software 3 02-15-2004 12:30 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:28 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration