Question

I have created a basic Noughts and Crosses game where it takes text input from the user to determine where the X/O will be placed (everything is printed on-screen using System.out) and it works fine within BlueJ, however when I create a .jar file it won't bring up a screen or do anything.

Any idea on what I am doing wrong?

Edit:

this is running on windows 7 and I'm attempting to run the application by double-clicking the .jar file.

I learned basic java through uni around 6 years ago and am re-teaching myself hence the uncertainty with running the application. To clarify, any executable file needs to contain a self-created manifest?

Was it helpful?

Solution

Did you define the Main-Class: entry in the jar's Manifest? If not, then here are some resources on the topic:

* http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html
* http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute

What OS and in what application do you double-click on the jar file? Typically each system (such as Windows Explorer) needs an association configured in order to know what you want it to do when you double-click. Perhaps that association is missing and so no program is run.

If your environment does, in fact, run java on the jar file and you have specified Main-Class in the manifest and yet no window appears in your graphical environment, then most likely your environment does not know that you intend for the program to be run in a console. You may need to adjust the associated program so that it runs java in a console or terminal program so that its stdout is visible. (Personally I normally open a terminal, on Ubuntu, and run 'java -jar' at the prompt)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top