LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 11-12-2004, 12:57 AM   #1
MRAB54
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 someCode.java" 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.

Edit:
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 01:18 AM.
 
Old 11-12-2004, 01:10 AM   #2
linux_terror
Member
 
Registered: Aug 2004
Location: Northbrook, Illinois
Distribution: CentOS-5
Posts: 311

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

#/usr/local/javac somecode.java

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.

linux_terror

Last edited by linux_terror; 11-12-2004 at 01:14 AM.
 
Old 11-12-2004, 02:09 AM   #3
IBall
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:
Code:
PATH=/path/to/java/bin:$PATH
JAVA_HOME=/path/to/java

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:
Code:
source .bash_profile
Now you should be able to compile your program using javac.

I hope this helps
--Ian

Last edited by IBall; 11-12-2004 at 08:30 PM.
 
Old 11-12-2004, 03:23 AM   #4
MRAB54
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, 03:42 PM   #5
zhangmaike
Member
 
Registered: Oct 2004
Distribution: Slackware
Posts: 376

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

Code:
PATH=/path/to/java/bin:$PATH
JAVA_HOME=/path/to/java

export PATH
export JAVA_HOME
 
Old 04-03-2005, 07: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, 08:18 AM   #7
lahrach.tdi
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.
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. http://learnjavaeasy.com/course/lear...8-by-examples/
 
  


Reply



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 07:41 PM
-bash: cp: command not found johnlittlepeap Fedora 2 11-15-2004 08:52 AM
-bash-- javac command not found nedian123 Programming 1 06-28-2004 04:16 PM
bash: command not found jc80 Fedora 3 03-14-2004 03:11 PM
J2sdk problem Javac command not found CollestonPie13 Linux - Software 3 02-15-2004 11:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:43 PM.

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