JME3 Create an exe file - doesn't work

Hey guys! Hope someone can help me :confused:

I have created a scene and would now like to save it as an exe. Unfortunately it does not work…
that’s why i tried it with the standard example - same problem …
Am I doing something wrong?
I have java14 so I tried Java11 in the engine
Sorry I’m total beginner :flushed:




you need to have java installed.
if you want it bundled with the application,
also select the last checkbox in the second screenshot (toghter with Windows 64-bit)

but I have Java :confused: I have Java 14 or what you mean?

and if I select the last checkbox in the second screenshot the build failed and shows me the same error as before :see_no_evil:

I know it is no help, but it doesn’t work for me either. It has the same error when I do a build.

I even went into the dist and tried to manually run the >jar file and still got an error.

Hi,

If you want run the .jar from command line check you have the right version of JAVA installed.
For all OS, to know your JAVA version (and if you have installed it) open a cmd and lunch this:

java -version

Ideally you have the same version set under Properties->Libraries->JavaPlatform.

To run the .jar copy/paste the command suggested from the builder, or open the cmd in the same folder where is placed your .jar and run:

java -jar nameFile.jar

If it doesn’t work read what is gone wrong, usually there is a self-explaining LOG, for example there are exceptions you have to fix before be able to run it.

Now my procedure to create a .exe and standalone software (example with Win64 and JDK11):
Compared to the request of the OP, I also want embedded the JDK in order to create a standalone software. In this way who run my game don’t need to install JAVA *(it have a cost, see below).

I suggest to proceed as follow:

  1. Generate the .jar (clean and build of your working project)

  2. Download the right version of JDK (the one you set in Properties->Libraries->JavaPlatform). Click here for windows x64 and jdk11.

  3. Download this tool: packr-all-x.y.z.jar

  4. Now considering you have in the same folder:

    • Your distribution files ( all the files you are going to find into the “dist” folder after the build of the project )
    • The JDK .zip downloaded at the point 2
    • The file packr-all-x.y.z.jar downloaded at the point 3 (in the example below the 4.0.0 version)
  5. You just have to open a cmd into the folder of the previous point and run the follow command (it works for the standard project MyGame):

java -jar packr-all-4.0.0.jar \
     --platform windows64 \
     --jdk OpenJDK11U-jdk_x64_windows_hotspot_11.0.13_8.zip \
     --useZgcIfSupportedOs \
     --executable MyGame \
     --classpath MyGame.jar \
     --mainclass mygame.Main \
     --vmargs Xmx2G \
     --resources lib \
     --output MyGame_WinX64

For a different project some values have to be changed, I strongly suggest to read here.

Keep in mind that in this way the project embedded the JDK and:

  • The size increase drastically;

  • The game will require more RAM.

I hope it could be useful :slight_smile:

The exception is NoSuchMethodError?

You’re using the wrong Java.

yes you were right, the engine platform was set to JDK11. So now I installed JDK11 on the laptop and deleted the old one (wrong version).

Unfortunately now I get a different error message when I want to open the jar-File:

c:\Users\alessa.foerster\Desktop\Test44\dist>java -jar MyGame.jar
Nov. 16, 2021 11:46:17 VORM. com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.3.2-SNAPSHOT

  • Branch: v3.3
  • Git Hash: 1ab3e92
  • Build Date: 2021-10-17
    Exception in thread “main” java.lang.UnsatisfiedLinkError: The required native library ‘bulletjme’ was not found in the classpath via ‘native/windows/x86_64/bulletjme.dll’. Error message: no bulletjme in java.library.path: [C:\Program Files\Java\jdk-11\bin, C:\Windows\Sun\Java\bin, C:\Windows\system32, C:\Windows, C:\Program Files\Java\jdk-11\bin, C:\Program Files (x86)\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin, C:\Users\alessa.foerster\Desktop\Python2.0\Eckdame, C:\Users\alessa.foerster\Desktop\Python2.0\chessmaster, C:\Windows\system32, C:\Windows, C:\Windows\System32\Wbem, C:\Windows\System32\WindowsPowerShell\v1.0, C:\Windows\SysWOW64\Empirum, C:\Program Files\MATLAB\R2020b\bin, C:\Program Files\dotnet, C:\Program Files (x86)\dotnet, C:\Program Files\nodejs, C:\Program Files\TortoiseGit\bin, C:\Program Files\apache-maven-3.8.1-bin\apache-maven-3.8.1\bin, C:\Program Files\Docker\Docker\resources\bin, C:\ProgramData\DockerDesktop\version-bin, C:\Users\alessa.foerster\AppData\Local\Programs\Python\Python38\Scripts, C:\Users\alessa.foerster\AppData\Local\Programs\Python\Python38, C:\Users\alessa.foerster\AppData\Local\Microsoft\WindowsApps, C:\Users\alessa.foerster\Desktop\Microsoft VS Code\bin, C:\Users\alessa.foerster\AppData\Roaming\npm, C:\Users\alessa.foerster\AppData\Local\GitHubDesktop\bin, C:\Users\alessa.foerster\AppData\Local\Programs\Git\cmd, .]
    at com.jme3.system.NativeLibraryLoader.loadNativeLibrary(NativeLibraryLoader.java:598)
    at com.jme3.system.JmeDesktopSystem.initialize(JmeDesktopSystem.java:348)
    at com.jme3.system.JmeDesktopSystem.newContext(JmeDesktopSystem.java:271)
    at com.jme3.system.JmeSystem.newContext(JmeSystem.java:159)
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:461)
    at com.jme3.app.LegacyApplication.start(LegacyApplication.java:424)
    at com.jme3.app.SimpleApplication.start(SimpleApplication.java:127)
    at mygame.Main.main(Main.java:19)

and when I want to open the created exe-file this comes up:


→ no bunbled runtime and can not find system JRE

this is in the engine when I want clear & build:
C:\Users\alessa.foerster\Desktop\Test44\nbproject\desktop-deployment-impl.xml:61: The following error occurred while executing this line:
C:\Users\alessa.foerster\Desktop\Test44\nbproject\desktop-deployment-impl.xml:65: src ‘C:\Users\alessa.foerster\Desktop\Test44\resources\desktop-deployment\jre-windows-x64.tar.gz’ doesn’t exist.

BUILD FAILED (total time: 3 seconds)
:woozy_face:

maybe you could try to download jre-8u202-windows-x64.tar.gz
rename it to jre-windows-x64.tar.gz and put it as
‘C:\Users\alessa.foerster\Desktop\Test44\resources\desktop-deployment\jre-windows-x64.tar.gz’

have tried it …unfortunately no

are you 100 % sure the path and the name is correct and its still the same error message?
also the exe you should start is in a .zip in the projectname/dist directory

I have now solved it for the time being by connecting JME3 with Eclipse. There I then created a Jar file and converted it with a converter into an exe…

it runs but unfortunately only objects that I have imported directly in the code are displayed. The scene with landscape is missing. :upside_down_face:

But thanks for your answers :slightly_smiling_face:

any answer from here?
https://docs.oracle.com/javase/tutorial/deployment/selfContainedApps/index.html

Just wonder, how you do this exec stuff. I tried packr but get then a

With the following command

java -jar packr-all-4.0.0.jar --platform windows64 --jdk C:\Users\liesc.jdks\corretto-15.0.2 --useZgcIfSupportedOs --executable MyGame --classpath lib\bubble.jar --mainclass ch.artificials.bubble.Main --vmargs Xmx2G --resources lib --output MyGame_WinX64

C:\Users\liesc\workspace\bubble\build\install\bubble\MyGame_WinX64>.\MyGame.exe

C:\Users\liesc\workspace\bubble\build\install\bubble\MyGame_WinX64>java.lang.NoClassDefFoundError: com/jme3/app/SimpleApplication
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151)
at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:514)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:422)
at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:416)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:415)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
Caused by: java.lang.ClassNotFoundException: com.jme3.app.SimpleApplication
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
… 10 more
Error: failed to load/find main class ch.artificials.bubble.Main

Wonder if you guys have a working setup for that? I mean it should be similar for various projects but seems not. This part always frustrated me the most. I once had it working for jfx. And again trying around and getting frustrated… a lot.

Anyway if there is some gradle way to “easily” make it work I would be glad to know about it :slight_smile:

Do you add JME libs to the classpath?

Here you may need to add all the jars your app depends on them as well.

I recently tried the JavaPackager Gradle plugin. It can create an exe launcher.

2 Likes

Thanks for the pointers. The pain goes on.
And of course yet another java packer :sweat_smile: I’ll have a look if that is easier. But it is an installer, I tried that already. Similar results.

I adjusted it now to this
java -jar packr-all-4.0.0.jar --platform windows64 --jdk C:\Users\liesc.jdks\corretto-15.0.2 --executable MyGame --classpath lib\ --mainclass ch.artificials.bubble.Main --output MyGame_WinX64

This generates an executable that I can run and now errors… But it just eats up 100% CPU but nothing happens.

Not sure but is it only me who wants an executable? So nobody did that before? I mean how do you distribute the game if you only have jars and need the players to install JRE? And doesn’t this look samish for many jMonkey games?

EDIT: I searched the internet and not too much information there. What once worked was this java fx thing. But somehow this needs now a license or so.

I’ll put it now aside as I get so frustrated with that, after hours of trying, not a clue what it does not like. And the parameters are so limited, there is not room for a lot more trials. So I still hope for someone which managed it :sweat_smile:

Just a note: often jstack and/or jconsole can be useful in these cases.

Thanks a lot.

Just in case somebody else is struggling with packr I found the solution I was just one wildcard away basically… well a bit more than that but here you go

java -jar packr-all-4.0.0.jar --platform windows64 --jdk C:\Users\liesc\.jdks\corretto-15.0.2 --executable bubble --classpath lib\* --mainclass ch.artificials.bubble.Main --resources assets --resources ..\..\..\
jinput-dx8_64.dll --resources ..\..\..\jinput-raw_64.dll --resources ..\..\..\lwjgl64.dll --resources ..\..\..\OpenAL64.dll --output bubble_64

The classpath must be lib\* not just lib. This puts everything next to the exec I mean jars and DLLs. And of course my asset folder as well. Hope this helps someone here.

1 Like

Normally there is a way to put relative classpaths right into the main jar’s manifest but I don’t know if it works through the separate packr tool. (It would be dumb if it didn’t.)

I’m actually surprised there is not better support for the classpath manifest in newer tools. It was something I really missed coming from ant to gradle originally.

1 Like