0

I am using Linux Mint, Apache ANT and a command line.

I am trying to write a game using LWJGL and am also developing a personal utility library at the same time. I am trying to create a runnable jar file of this game. Using ANT I have created a jar file with all of my classes for the game and a manifest specifying the main class to run and a classpath. My problem is that when I run the game using

java -cp library.jar -jar game.jar

I get a class not found error on a class from library.jar.

If I run the game main class by going

java -cp bin:library.jar game.MainClass

The game runs fine, but the jar won't work. I have expanded the jar file and read the manifest, the class files are all there with the right directory structure (no bin directory, starts with game) and the manifest seems fine. I've tried including the current directory into the classpath (.:library.jar) and I have tried giving a full path to the jar rather than a local path.

Besides actually expanding the entire library.jar into my game.jar how can I fix this? I can give more specific directory information if necessary.

HonestHeuristic
  • 336
  • 2
  • 14
  • What does *the game runs fine, but the jar won't work* mean? Oh, *Besides actually expanding the entire library.jar into my game.jar how can I fix this?* Sorry. Yes, you have to do that to run it as a jar. – Elliott Frisch Aug 20 '14 at 03:06
  • It means that using the class file with the classpath including the library.jar works fine but using the game.jar with the classpath including the library.jar doesn't. That is my problem – HonestHeuristic Aug 20 '14 at 03:09
  • Are you saying that is is impossible to run a jar that uses classes from another jar? – HonestHeuristic Aug 20 '14 at 03:10
  • 1
    okay for the record I found a mistake in my classpath declaration in the Manifest file. I can now include other jar files by adding them to the manifest file but I'm not sure why it won't work from the command line – HonestHeuristic Aug 20 '14 at 03:21
  • possible duplicate of [Cannot find Main Class in File Compiled With Ant](http://stackoverflow.com/questions/3143567/cannot-find-main-class-in-file-compiled-with-ant) – Mark O'Connor Aug 20 '14 at 21:16

0 Answers0