Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Intellij IDEA 14.1.4: Cannot run program "C:/Program Files (x86)/Java/jdk1.8.0_45/bin/java"

I am trying to run a java-based Play 2.0 app in IDEA, but upon compilation, I get this error:

Information:Internal caches are corrupted or have outdated format, forcing project rebuild: Module 'web-server' production: java.io.IOException: Cannot run program "C:/Program Files (x86)/Java/jdk1.8.0_45/bin/java" (in directory "C:\Users\\Documents\GitHub\\web-server"): CreateProcess error=267, The directory name is invalid

This occurs during a ProcessBuilder.start() action.

I have made sure all the path variables are properly set, even changing them up to ensure that they work properly. The thing that gets me here is that it seems like ProcessBuilder is trying to use forward slash paths, but I'm running in Windows.

I've tried reloading my project from scratch, invalidating the cache and restarting, updating my java installation (both 32- and 64-bit), and uninstalling and reinstallating IDEA, but it just won't seem to work. This same project runs fine on another computer, so I'm thinking it might be a local issue. Any help would be greatly appreciated!

like image 581
Matt Kindy Avatar asked Jul 06 '15 05:07

Matt Kindy


2 Answers

I had this problem recently, i solved in 2 steps.

Part 1

If your path JAVA_HOME is OK:

File → Settings → Build, Execution, Deployment → Build Tools → Maven → Runner

Set to "use JAVA_HOME (...Path...)"

If you set with a fixed string, the problem may reappear when in future you will re-update. Anyway, you can do that.

Part 2

File → Other Settings → Default Project Structure

Check all the tabs and ensure that all the path point to the newly installed JDK (If you change in one, then you should have all changed, e.g. i changed in Annotations)

If you cannot select the path (error: not valid path), try not to use the one in C:\Program Files (x86)\Java...\ -- select the one in C:\Program Files\Java...\ (or viceversa)

like image 151
fresko Avatar answered Nov 15 '22 10:11

fresko


I had the same issue, here is how I solved it:

Clearly there is something wrong with the directory path. Mine was "D:\IntelliJ Workspace\" but in error message it was "D:\IntelliJ+Workspace\". When I remove the space in directory name the error was fixed.

In your situation "C:\Users\\Documents\GitHub\\web-server" has extra back slashes so when you fix this, I think your error will be fixed.

like image 32
neandertal Avatar answered Nov 15 '22 12:11

neandertal