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

9

11

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!

Piccoloist answered 6/7, 2015 at 5:10 Comment(0)
V
3

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.

Vestibule answered 9/7, 2015 at 8:45 Comment(1)
The double backspaces here indicate that there are other folder between Users and Documents, but similarly to what you said, my specific User directory contained spaces.Piccoloist
M
15

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)

Mages answered 26/4, 2016 at 11:10 Comment(1)
I had to go to File -> Project Structure and change the Project SDKUnreal
V
3

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.

Vestibule answered 9/7, 2015 at 8:45 Comment(1)
The double backspaces here indicate that there are other folder between Users and Documents, but similarly to what you said, my specific User directory contained spaces.Piccoloist
M
1

Had the same issue as the folder containing the project has spaces in its name. Worked perfectly after removing the spaces and renaming it.

Mcadams answered 16/12, 2016 at 10:51 Comment(1)
this should be in comment not in answer.Liqueur
G
1

I had a similar issue-
Cannot run program "E:\Java\jdk-17.0.2\bin\java.exe" (in directory with idea 14.1.4)

Solution:
1.Delete your jdk
1.Reinstall your jdk.
2.Then again build your project and save,run it.

Ghassan answered 26/2, 2022 at 3:15 Comment(1)
Thank you for the advice, mvn install did the job and fixed the issueLandan
U
1

I think my Java was updated or so.

Go to File | Project Structure | SDKs and check your SDK

Go to File → Settings → Build, Execution, Deployment → Build Tools → Maven → Runner as suggested in other posts and select the correct JDK.

Sources: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360009821700-Cannot-find-JDK-for-module

Unattached answered 7/8, 2023 at 8:39 Comment(0)
S
0

I had same issue with idea 14.1.4. Changing Maven Runner option to Use JAVA_HOME helped. Settings > Maven > Runner Set JRE to Use JAVA_HOME.

Stoffel answered 25/8, 2015 at 7:47 Comment(0)
P
0

i changed from jdk1.7 to jdk1.8.0_212 and it worked however during compile time i am usind jdk 1.7 and in run time its jdk1.8.0_212

Phasia answered 1/8, 2019 at 14:48 Comment(0)
A
0

I had to restart the machine after installing new jdk version post that as mentioned above, I selected the right jdk using File → Settings → Build, Execution, Deployment → Build Tools → Maven → Runner. It worked for me.

Antipope answered 11/7, 2023 at 10:41 Comment(0)
B
0

I have the same problem. Please use the below steps to fix the problem.

  • Go to IntelliJ Settings-> Build, Execution, Deployment-> Build Tools->Maven-> Runner
  • Inside Environment variables put JAVA_HOME path
    example: JAVA_HOME=C:\Programs Files\Java\jdk1.8
  • Restart your IntelliJ

It works.

Bonzer answered 20/4 at 18:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.