2
votes

I'm having a very hard time making a simple Play 2 project (Scala) to work with IntelliJ on Windows 8 64-bit. I made a project and always get the error:

Play 2 compiler
:  (compile:compile) java.io.IOException: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified

I added javac to my path ("C:\Program Files\Java\jdk1.7.0_45\bin") and even JAVA_HOME (set to "C:\Program Files\Java\jdk1.7.0_45"). I works: I can call javac from the command prompt... but I still get the same annoying error when I try to Make the project with IntelliJ.

What I did, step by step:

  1. Install jdk-7u45-windows-x64.exe. Add to PATH.
  2. Install latest IntelliJ IDEA 12 (Ultimate)
  3. Open IntelliJ and install Scala and Play plugins.
  4. Create a new Play framework project, select JDK and a version of Play (2.1).
  5. Try to build the basic project without making any modification to the code and get the javac error.

I'm completely new to IntelliJ (I hope it gets more fun!) but looking at "Project Structure": everything looks fine, bth the Java SDK and Scala 2.10 compilers are selected...

4
Don't know if you already solved your problem, but having double quotes in my PATH ("C:\Program Files\...") was causing this issue for me. I could call javac from the command prompt, but it failed when called from IntelliJ and PowerShell. Removing the double quotes made it work everywhere. - rla4♦

4 Answers

2
votes

I too got this error when I started my Sample Play App using Activator 1.0.13. I checked my JAVA_HOME and it was showing the correct installation path. To solve this problem, I entered into the console and issued following command:-

set javaHome := Some(new java.io.File("/usr/lib/jvm/jdk1.7.0_45"))

After this, it started working.

1
votes

even though you might have jdk bin directory in PATH env variable, this problem can occur. To fix this, put path of jdk bin (not of jre bin) at the beginning of PATH env variable, just in case any other PATH value is getting picked up first for javac (might have jre bin dir also in PATH env variable before..for example)

0
votes

It's evident that your java installation did not complete successfully

at your command prompt type: java -version

If it works, next step is to ensure that 'javac' is on system/user PATH

  1. Add this to your bash profile

export $PATH=$PATH:${JAVA_HOME_DIR}/bin

Reinitialize your profile by executing

source ~/.bash_profile

Then retry.

0
votes

if you are using play 2.1.X then go to your project directory and inside there is a folder name project . go also inside this directory also and you will find out one file is there Build.scala and open this file and inside this file

write javaCore inside app dependecy in build.scala

like this

 val appDependencies = Seq(
      javaCore
    )

i think it will help you