[Solved] Call java.exe or simply java

The main question is, if somebody knows exactly whats the difference in windows 10 between simply calling “java -jar …” or “java.exe -jar”.

Reason behind this question, since updating my rig (including a new gtx1060 card) I got this exception:

SEVERE: Failed to create display
org.lwjgl.LWJGLException: Pixel format not accelerated
        at org.lwjgl.opengl.WindowsPeerInfo.nChoosePixelFormat(Native Method)
        at org.lwjgl.opengl.WindowsPeerInfo.choosePixelFormat(WindowsPeerInfo.java:52)
        at org.lwjgl.opengl.WindowsDisplay.createWindow(WindowsDisplay.java:247)
        at org.lwjgl.opengl.Display.createWindow(Display.java:306)
        at org.lwjgl.opengl.Display.create(Display.java:848)
        at org.lwjgl.opengl.Display.create(Display.java:757)
        at com.jme3.system.lwjgl.LwjglDisplay.createContext(LwjglDisplay.java:143)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:113)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:211)
        at java.lang.Thread.run(Unknown Source)

Most probably some of you might either say driver issue, or something in my application. So I reduced my application to this:

(new SimpleApplication() {
            @Override
            public void simpleInitApp() {
            }
        }).start();

and still got the same exception (Btw - always after confirming the settings dialog, doesn’t matter what is selected).

I was already a little bit down, because I thought its because of the driver from the new graphics card, when it suddenly was working again.

But because I was not aware of having changed anything I tried to track the reason down and came up to a reproducable test case (at least on my system):

When starting the application using exactly this command:

java -jar srb-game-client-1.0.0-SNAPSHOT.jar

it crashed with the exception from before.

But when calling it with this:

java.exe -jar srb-game-client-1.0.0-SNAPSHOT.jar

it is working! Same working directory, same path, same environment, same session (command shell)… Really checked it at least 10 times, because I could not believe that its working just because of including the extension of the java vm…

And now I am kind of stuck. I checked -version for both variants: w/ and w/o the extension and both print the same information:

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

I already was thinking of maybe there is a java.bat somewhere in the path which is executed instead of the java.exe and causes the problems, but found none…

Does somebody have an idea - I mean its quite easy for me to fix it by just calling java.exe instead, but I really want to understand this…

Could it be related to this?

1 Like

Maybe… Need to give it a try! Let you know the result, soonish… thx for the hint!

I have not read the superuser thread but maybe java points to SOME java installation on your pc, probably the 32bit version while java.exe launches the appropriate version.

What you can also try is going into the bios and disabling the internal intel gpu. On the other hand some people play with that so it should also work with the iGPU

Then the output of java.exe -version and java -version would have been different.

If there was a ‘which’ command installed it would be easy to check. I instinctively install cygwin on all of my windows boxes so I don’t even know if windows has a ‘which’ command by default.

1 Like

From what I’ve read on the internet this is related to the faulty nvidia drivers which claim they have no opengl support. I thought they fixed them already though.

Dev of StarMade said it on reddit somewhere I think.

1 Like

Checked a few things, but still is not working.

PATHEXT environment is

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

Which is ok I think. I checked the path and there is only a java.exe, no java.bat, java.cmd, …

There is no “which” command, but an “where” command available. But both java and java.exe points to:

C:\ProgramData\Oracle\Java\javapath\java.exe

Which might be true or not - depending on how much you want to trust this ms where :wink:

I also just now tried it with powershell and there both the java and the java.exe call is working…

I was also thinking on what could cause that the opengl initialization is failing when just calling “java”, that might be different when calling “java.exe”. Maybe some security issue when accessing the lwgl.dll - but this would result in another error, or? or an old version of lwgl.dll? Because in my experience even when loading the 32bit .dll instead of the .64 would result in a different error…

But then it would not work at all, right?

rename java.exe to xxxx.exe and try

xxxx -jar srb-game-client-1.0.0-SNAPSHOT.jar

and

xxxx.exe -jar srb-game-client-1.0.0-SNAPSHOT.jar

https://nvidia.custhelp.com/app/answers/detail/a_id/4378 could be

1 Like

I’m glad that was so fast.

This fixed the issue! Still don’t know why it was working with java.exe but not with simply java before, but now its working.

Let me elaborate on this a little bit more, because it might be of use to someone;)

I already had this “minecraft” issue this driver hotfix is mentioning in the release notes - but not with minecraft (actually never played it), but with “normal” java applications that create windows. It did not matter if it was a swing application or a JFX or a JME app. The jvm just crashed when creating a window. The funny thing about this was, that it did not happen always. E.g. when a created just a “hello world” using JFX the window was created, but as soon as I included the controlsfx.jar in the classpath it crashed while creating the window (without changing the program at all - really just because of including a jar in the classpath).

I was already frustrated at that point (building a new rig and then everything is working fine apart from the stuff → java that was the reason for buying one in the first place), but then I started debugging the JVM and found the crash actually happens inside nvSCPAPI64.dll (some null reference pointer).

After googling this I found some minecraft forum entries that suggested to uninstall the “3d Vision Driver” and after this everything (except this simply java stuff) worked fine again.

Apparently this was not the only thing nvidia fixed. But I am happy that they did it that fast and now its working again. I am still curious whats actually the difference between calling java.exe or simply java that causes a different behaviour, because up until now I was “pretty certain” that it should be the same…

Anyway, thanks a lot to all of you - still always amazed how fast and good this community works!

Glad it worked. The thing I may assume is that nVidia driver parses environment from where it was called and if it finds “java” it does some java-specific setup. I don’t know if that’s cmd-specific problem (environments aren’t equal with .exe and w/o) or nvidia’s parser problem. Anyway, all that is nVidia magic since they fixed it.

1 Like