Reputation: 55
When opening Eclipse I can write and run programs in Java, but when I enter javac programname.java, it says the file can not be found.
In short: eclipse is finding the jre7 but cmd (even after making sure file was in the path cmd was looking in), cmd wont execute the programs.
How can I fix this?
Upvotes: 2
Views: 148
Reputation: 2738
Seems to be your java installation is corrupted. I think you should reinstall java. also You should ensure that you're installing the right jre for your architecture.
If you go in to this link since you are getting cfg error, you will get the exact answer Go to this
Upvotes: 0
Reputation: 5736
I believe your environment variable is not set properly.
If you are using windows then create a System Variable JAVA_HOME
with the path of the jdk
JAVA_HOME = C:\Program Files\Java\jdk1.7.0_45
Then add this in the Path
variable %JAVA_HOME%\bin
If you are using Linux then do the following :
$
vim /etc/profile
And at the end of the file include the following lines. Wherever you have unzipped the java directory add that path only.
export JAVA_HOME=/usr/java/jdk1.7.0_45
export PATH=$PATH:/usr/java/jdk1.7.0_45/bin
For other shell's in Unix , Have a look at the JDK Doc.
Upvotes: 0
Reputation: 20003
Eclipse does not require "javac" to compile Java source files since its JDT project supplies a compiler of its own. It's entirely possible that you do not have javac--it requires installing the JDK, not just the JRE that Eclipse itself requires--and that it would not be on your path as a result.
Upvotes: 2