0

So I have a Java window in Eclipse, and it has no errors or warnings. Here is that:

Application image

It launches just fine when I run it in Eclipse, and I've exported programs before like this, but when I export it to a JAR file and run it, it loads for a split second and then no window appears (the application doesn't show up in the task manager either). Here's my settings for the build:

Build Settings image

It builds just fine, but when clicked, it doesn't open the window! What am I doing wrong here?

tdog
  • 169
  • 2
  • 11

2 Answers2

0

This is just a guess, but you MIGHT need this flag on startup: -XstartOnFirstThread

Joseph Larson
  • 8,530
  • 1
  • 19
  • 36
  • How do you flag something on startup? – tdog Aug 16 '18 at 16:16
  • java -jar foo.jar -XstartOnFirstThread. There is probably some way to make it a clickable jar, but you'll need to research for that. – Joseph Larson Aug 16 '18 at 16:19
  • It says "no main manifest attribute, in AudioAdjuster.jar". I'll try converting the JAR into an EXE and see if that solves anything. – tdog Aug 16 '18 at 16:22
  • That flag is normally only needed on macOS and even then only for SWT/GWT apps (see [here](https://stackoverflow.com/q/28149634/2670892)). – greg-449 Aug 16 '18 at 16:24
  • Nope, the window still doesn't open after converting it with launch4j. – tdog Aug 16 '18 at 16:28
0

According to the picture you added, you are not exporting your project as a runnable JAR file. A runnable JAR includes the MANIFEST.MF, which defines the Main class to be executed when you run the JAR.

Right Click on project -> Export -> Java -> Runnable JAR file, on the next screen select your Main class and define export destination and check "Extract required libraries into generated JAR.

R. Steijn
  • 1
  • 2