rross
rross

Reputation: 2276

Play framework can't find javac

I'm following a play tutorial when I run the web server before making any changes to the app. The server throws an error:

IOException: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified

I check my JAVA_HOME and it reads C:\Program Files\Java\jdk1.7.0_25. How would one fix this issue?

Upvotes: 25

Views: 30398

Answers (5)

Heisenbug
Heisenbug

Reputation: 484

I was using the downloaded JDK as Installed JRE's in eclipse and facing error.

Then I tried to search the JDK which is installed by sudo apt which resides in

/usr/lib/jvm/java-11-openjdk-amd64

Upon selecting this JDK, everything started working fine.

enter image description here

Upvotes: 0

MadProgrammer
MadProgrammer

Reputation: 347314

Make sure that the javac is in the OS's search path

For example, on Windows, goto Control Panel -> System, click Advanced System Settings, click on Environment Variables.

In the System variables, locate the variable named path and insert C:\Program Files\Java\jdk1.7.0_25\bin at the start of the value. Don't forget to add ; between the values ;)

enter image description hereenter image description here

Click Okay, Okay.

Close any command prompt windows you have open and re-open them. This will ensure that they are updated with the new environment variables.

Upvotes: 43

maudulus
maudulus

Reputation: 11035

I wasn't aware that the typical java install DOES NOT have javac. Thus, I did the following:

1) Visited the Java SE Development Kit site

2) Downloaded the version for my Operating System and installed it

3) went to the root folder of the newly Java SE Development Kit (in this case C:\Program Files (x86)\Java\jdk1.8.0_31\bin)

4)Using the windows search, entered environment variables, which brings up the option Edit the system environment variables on Windows 7

5) clicked on Environment Variables in the System Properties tab that should have opened.

6) with PATH highlighted, clicked Edit...

7) Added ;(a semi-colon to seperate this new path from the old) + C:\Program Files (x86)\Java\jdk1.8.0_31\bin (make sure there is no space between the semi-colon and the new path.

Upvotes: 4

skhurana
skhurana

Reputation: 91

Even though you might have the JDK bin directory in your PATH environment variable, this problem can occur. To fix it, put the path of JDK bin directory (not the JRE one) at the beginning of the PATH variable, just in case javac is getting picked up in the wrong directory because the wrong directory happens to be first.

Upvotes: 0

victorf
victorf

Reputation: 1048

Don't forget to check your system access. You should have all access power during the instalation or setting process. I just had to require full OS access (Windows, in the big company) to solve this issue and now it's all ok.

Upvotes: 0

Related Questions