ide-java icon indicating copy to clipboard operation
ide-java copied to clipboard

No Java runtime found

Open wendymungovan opened this issue 6 years ago • 8 comments

I just installed atom and ide-java on linux mint. No matter what I set the java home to for IDE-java I get a IDE-Java could not lanuch your java runtime. No java runtime found at:... error.

I've tried several things restarted, set the environment variable for JAVA_HOME (/usr/lib/jvm/java-11-openjdk-amd64), re-installed ide-java. java and javac work fine from the command line and atom just does not seem to be able to see it. The only thing in the console window is: Uncaught (in promise) undefined ... server-manager.js line 5 over and over.

Any help you have would be great. Thank you.

wendymungovan avatar Dec 20 '18 01:12 wendymungovan

I know its a little old, but I was having a similar issue, try to setup the bin folder of this JAVA_HOME inside your PATH variable. https://stackoverflow.com/questions/19013725/linux-mint-adding-environment-variables-permanently

marcelovue avatar Jan 19 '19 11:01 marcelovue

Thanks - I'm still having the problem so I will take any help i can get. :)

$ more .pam_environment JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/bin/ PATH DEFAULT=${PATH}:${JAVA_HOME}

and then restarted atom. I'm still having the same problem (i tried with and with out the bin folder specified).

I thought it might be a permissions problem but everyone has access to java and javac (same permissions not shown). Does atom run a nobody?

$ ls -la /usr/lib/jvm/java-11-openjdk-amd64/bin/java -rwxr-xr-x 1 root root 10344 Nov 13 07:53 /usr/lib/jvm/java-11-openjdk-amd64/bin/java

wendymungovan avatar Jan 22 '19 15:01 wendymungovan

JAVA_HOME variable is not supposed to have the /bin directory, I'm not sure about how u set ur system up, but I think it could be like so:

JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
PATH DEFAULT=${JAVA_HOME}/bin

At least it is what we do in windows.

marcelovue avatar Jan 22 '19 19:01 marcelovue

That still does not do it.

wendymungovan avatar Feb 26 '19 23:02 wendymungovan

I have the same issue using it on Fedora r31 Didn't found a solution yet.

LJacobsonMT avatar Feb 19 '20 18:02 LJacobsonMT

I've been facing the same issue on mac os - though the java path is set correctly, I still get "Error: Could not find or load main class'".

Appreciate if anyone can help me

PVoola avatar Jun 26 '20 10:06 PVoola

In your ide java configuration, remove the bin folder directory... It should now look like something like this C:\Program Filess\Java\jdk-11.0.8
Good luck...

xenonwellz avatar Oct 12 '20 14:10 xenonwellz

Hi, I've found that the error comes from the code of the module. Even if the JAVA_HOME, JDK_HOME are set correctly in environment variable or settings in atom. Ex: C:\path\to\openjdk\jdk-17.0.4.101-hotspot\ The module will throw an error if the command java -showversion cannot be parsed correctly

Ide-java access the java path with the follow code:

  getJavaPath () {
    return (new Array(
      atom.config.get('ide-java.javaHome'),
      process.env['JDK_HOME'],
      process.env['JAVA_HOME'])
    ).find(j => j)
  }

When Java path is set correctly following one of the 3 ways (in settings, or in environment variables of OS) The module check for the version of java using a regex pattern for finding the version of Java.

  getJavaVersionFromOutput (output) {

    const match = output.match(/ version "(\d+(.\d+)?)(.\d+)?(_\d+)?(?:-\w+)?"/)
    return match != null && match.length > 0 ? Number(match[1]) : null
  }

The problem is that with the OpenJDK version 17.0.4.1, the regex will return null.

"openjdk version \"17.0.4.1\" 2022-08-12 OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1) OpenJDK 64-Bit Server VM Temurin-17.0.4.1+1 (build 17.0.4.1+1, mixed mode, sharing)"

The code below returns null.

'openjdk version "17.0.4.1" 2022-08-12 OpenJDK Runtime Environment Temurin-17.0.4.1+1 (build 17.0.4.1+1) OpenJDK 64-Bit Server VM Temurin-17.0.4.1+1 (build 17.0.4.1+1, mixed mode, sharing)'.match(/ version "(\d+(.\d+)?)(.\d+)?(_\d+)?(?:-\w+)?"/)

The solution would be to adapt the regex pattern for all possible output version. The second sub-group starting from the last of the regex pattern (_\d+)? in my case is the one causing the error. If the arrow base was intented, may be a solution like ((_\d+)?|(.\d+)?) would solve the problem. Or simply changing the arrow base to a dot, if the arrow base was unintended.

iracanyes avatar Oct 07 '22 05:10 iracanyes