Error invoking method, failed to launch jvm
Solution 1:
I ran into the same problem; the following worked for me and helped me make sense of those blasted "Error invoking method." and "Failed to launch JVM" dialogs:
- Find your
.jar
file- It has the same name as your Project and it's in your application's installation directory under
AppData\Local\{ApplicationTitle}\app
(shortcut: type %appdata% into explorer); if your project was named HelloWorld, there you will findHelloWorld.jar
- It has the same name as your Project and it's in your application's installation directory under
- Navigate to it's directory in command prompt
-
shift+Right Click any blank spot in the Explorer window and choose "Open command window here" (that's a fancy trick I recently learned; alternatively you would
cd
to the same directory using the command prompt)
-
shift+Right Click any blank spot in the Explorer window and choose "Open command window here" (that's a fancy trick I recently learned; alternatively you would
- Run your
.jar
via the command line- type
java -jar "HelloWorld.jar"
and hit Enter
- type
Tadah! Behold your hidden exceptions (the existence of which "Error invoking method." so vaguely tries to communicate to you). *
If your problem is similar to mine it stems from a file structure difference between the project out
folder and the installation directory, and that's why the program compiles just fine in the editor and builds just fine—there isn't a problem until it's built out, and the file structure is a little different.
*If you didn't get anything when you ran it via the command line, look for any errors that could be happening during that initialize()
method; that's where your problem likely is. You can expose any exceptions during runtime by using a Popup Exception Dialog like shown in a similar problem, here.
Solution 2:
This is probably because it lacks the dependencies in the output jar. So you need to add the libraries in the artifact and then .exe generation should be ok.
Here is an example with Intellij, where the libraries have be manually moved from "Available Elements" to the artifact
Intellij example