0
votes

I finished my program and now i am trying to create a jar file to run it from, but when i try to do so, nothing happens, no error, not execution, no nothing.This is the path: D:\Eclipse\workspace\Game\src\AppPackage I compiled my class D:\Eclipse\workspace\Game\src\AppPackage javac Game.java Created my manifest and jar file : echo Main-Class: Game >manifest.txt and jar cvfm Game.jar manifest.txt *.class

This is how i add a image from the images folder :

field.setIcon(new ImageIcon("images/8.png"));
2
What happens when you try to run it with java -jar Game.jar from the command line?Jon Skeet
Why don't you use Eclipse to create the jar?Francesco Palmiotto
Manifest files have a ".mf" mime type. Read this.Stefan
@JonSkeet It gives me an error : Error: Could not find or load main class GameAXL
Does it have anything to do with the fact that my program is actually a GUI and that i have a separate folder( next to "src" folder) called images where i have my images ?AXL

2 Answers

0
votes

You try to load the class Game from default package. But the path says you have the class in the AppPackage package. So Class should be AppPackage.Game Also: you should use the IDE function to make the jar since only then the data gets packed together correctly. Afaik every IDE got a feature for that

0
votes

Have a look at this tutorial: Creating a JAR File.

For your case, first of all you have to run the jar command from the src folder. For the Main-Class you have to specify the fully qualified name of the class, that means including the package: AppPackage.Game.

To include any other folder you just write it in the command line, like this:

jar cvfm Game.jar manifest.txt *.class images

You can get more details in the link.