GPP
GPP

Reputation: 71

Unable to find javac

I have been trying to get an automated system for the video game minecraft to work. I have to compile it myself, and after following the guide EXACTLY, I get this when running the build.xml with ANT. Below is the code and the error in it.


Buildfile: C:\Users\Arm\workspace\DarkBot\build.xml
init:
clean:
   [delete] Deleting directory C:\Users\Arm\workspace\DarkBot\bin
 compile:
    [mkdir] Created dir: C:\Users\Arm\workspace\DarkBot\bin

BUILD FAILED
C:\Users\Arm\workspace\DarkBot\build.xml:21: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files (x86)\jre1.8.0_25"

What am I doing wrong? Also I can assure that JAVA_HOME points to the correct area, as suggested in the error message.

Upvotes: 5

Views: 10834

Answers (4)

Syed Zaidi
Syed Zaidi

Reputation: 1

If you can not find the path after testing on the command prompt and it says something like 'error java not found or it is not available from the internal or external .....' then follow the steps below:

Go to C:\Program Files\Java\jdk1.7.0_76\bin this shows the location of your java bin copy the path shown.

Go to Mycomputer > system properties > advanced settings> Click on Environmental Variables > (check this closesly... on the second section of the window where it says 'System Variables' scroll down the list till you find 'path' on the left)

click on the 'path' found from the list of system variables and click 'edit'.

Now paste your copied link in my case C:\Program Files\Java\jdk1.7.0_76\bin

Click Ok and go back to command prompt and test it. I hope this helps as mine is working now.

Upvotes: 0

Pawankumar Dubey
Pawankumar Dubey

Reputation: 387

Install JDK , JDK compiles your program and it has javac in bin folder like this "C:\Program Files\Java\jdk1.7.0_51\bin".

Set its path in Environment variables either in system variables "path" key or as "JAVA_HOME"

you can try Uninstalling and Re-installing already installed one.

Upvotes: 1

Ankur Singhal
Ankur Singhal

Reputation: 26077

All ant stuff will work fine except the javac task which needs the tools.jar, located in the /lib directory from the JDK, JRE is not sufficient in that case.

eclipse setting

Right Click build.xml ---> Build path ---> configure buildpath ---> select libraries tab

click "Add library" ---> double click on [jre system library ] ---> environments ---> installed jres ---> Add ---> standard vm

click on directory ---> Browse upto jdk [C:\Program Files\Java\jdk1.7.0_01]

finish

change the selection jre to jdk ---> click ok

Upvotes: 0

Raptor
Raptor

Reputation: 54252

JRE is not equal to JDK.

  • JRE stands for Java Runtime Environment, which is used to RUN Java programs.
  • JDK stands for Java Development Kit, which is used to COMPILE Java programs; it includes javac, the Java compiler.

Install JDK and points JAVA_HOME to correct location to resolve your issue.

Upvotes: 6

Related Questions