Greetings all. I have seen a few "Executable Jar" threads in the past, thought I might add one myself.
Background: I checked out JME into Eclipse using the standard tutorial. Directory structure is normal – src/ contains .java files, bin/ contains .class files, lib/ contains .jar files.
I am using an ant script to build an executable .jar:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Execute .jar by doing: java -Djava.library.path=./lib/ -jar buildjar.jar -->
<project name="SAGE" default="SAGEmain" basedir=".">
<attribute name="Main-Class" value="cave.CLASSManager"/>
<attribute name="Class-Path" value=". ./lib/FengGUI.jar ./lib/hsqldb.jar ./lib/jinput.jar ./lib/jogg-0.0.7.jar ./lib/jorbis-0.0.15.jar ./lib/junit-4.1.jar ./lib/lwjgl.jar ./lib/lwjgl_util_applet.jar"/>
When I try running it, using java -Djava.library.path=./lib/ -jar buildjar.jar, I receive:
Exception in thread "main" java.lang.NoClassDefFoundError: cave/CLASSManager
However, I define the Main-Class, unpacking the .jar shows that it exists in bin/cave/CLASSManager.class.
Any ideas? Thanks in advance :).
doesn't the class dirs need to be in the top of the jar, not in some bin dir?
This is my first time using Ant, so I'm not sure – I do know that changing the Main-Class to something like bin/cave.CLASSManager did not work.
To try your method, I'd just copy everything in bin/ to my root folder? Will try now.
Edit: Thank you very much! That works splendidly.
Seeing that you are an admin here – I'm not trying to be a one-post newb on the forums. I'll start trying to help others as penance for requiring your help :).
Uhhh… hmmm… mine doesn't seem to work. I get:
Exception in thread "main" java.lang.NoClassDefFoundError: Euphrates (wrong name: jmetest/ARK/Euphrates)
at java.lang.ClassLoader.defineClass1(Native Method)
Which seems better than the alternative that I get when I type something that I know is wrong...
Exception in thread "main" java.lang.NoClassDefFoundError: Euphrates.bunny
All of my class files are at the top of the jar when you open it... including Euphrates.class... the item that it can't find.
EDIT: As suggested in another post, dumping the lib folder into the dir you are working out of fixes that problem...
I'm so close to being able to send my game demo to my friends... yet so far away... The jar finally works but all path references fail for the classes inside :(
I'm sure there is a simple solution but it seems that no one else is having this problem...
How do you set the working directory to be the jar itself???
I figured that would be the default but it isn't working
None of these work and I've already checked inside the jar file and confirmed that it is there...
Can I do it from the ant build script? None of the setting working directory commands that I found online worked...