Can't make a jar with eclipse 3.2 on MacOSX =>"no lwjgl in java.library.path"

hi

i try to make an executable jar on macosx with eclipse 3.2

i have my project running fine with test => "Application java"

thi is my .classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
   <classpathentry kind="src" path="src"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
   <classpathentry kind="output" path="bin"/>
<!-- LWJGL -->
   <classpathentry kind="lib" path="jar/lib/lwjgl_util_applet.jar"/>
   <classpathentry kind="lib" path="jar/lib/junit-4.1.jar"/>
   <classpathentry kind="lib" path="jar/lib/jorbis-0.0.15.jar"/>
   <classpathentry kind="lib" path="jar/lib/jogg-0.0.7.jar"/>
   <classpathentry kind="lib" path="jar/lib/jinput.jar"/>
   <classpathentry kind="lib" path="jar/lib/odejava-jni.jar"/>
   <classpathentry kind="lib" path="jar/lib/lwjgl.jar">
      <attributes>
         <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="chandelier/jar"/>
      </attributes>
   </classpathentry>
<!-- / LWJGL -->   
   <classpathentry kind="lib" path="jar/jmetest.jar"/>
   <classpathentry kind="lib" path="jar/jme.jar"/>
   <classpathentry kind="lib" path="jar/jme-xml.jar"/>
   <classpathentry kind="lib" path="jar/jme-terrain.jar"/>
   <classpathentry kind="lib" path="jar/jme-scene.jar"/>
   <classpathentry kind="lib" path="jar/jme-physics.jar"/>
   <classpathentry kind="lib" path="jar/jme-model.jar"/>
   <classpathentry kind="lib" path="jar/jme-gamestates.jar"/>
   <classpathentry kind="lib" path="jar/jme-font.jar"/>
   <classpathentry kind="lib" path="jar/jme-effects.jar"/>
   <classpathentry kind="lib" path="jar/jme-editors.jar"/>
   <classpathentry kind="lib" path="jar/jme-collada.jar"/>
   <classpathentry kind="lib" path="jar/jme-awt.jar"/>
   <classpathentry kind="lib" path="jar/jme-audio.jar"/>
<!-- INPORTS -->   
   <classpathentry kind="lib" path="jar/oscP5.jar"/>
   <classpathentry kind="lib" path="jar/core.jar"/>
</classpath>


my build.xml :

<?xml version="1.0" encoding="UTF-8"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. -->
<project basedir="." default="build" name="chandelier">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../../../../Applications/interactions/eclipse"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.5"/>
    <property name="source" value="1.5"/>
    <path id="chandelier.classpath">
        <pathelement location="bin"/>
        <pathelement location="jar/lib/lwjgl_util_applet.jar"/>
        <pathelement location="jar/lib/junit-4.1.jar"/>
        <pathelement location="jar/lib/jorbis-0.0.15.jar"/>
        <pathelement location="jar/lib/jogg-0.0.7.jar"/>
        <pathelement location="jar/lib/jinput.jar"/>
        <pathelement location="jar/lib/odejava-jni.jar"/>
        <pathelement location="jar/lib/lwjgl.jar"/>
        <pathelement location="jar/jmetest.jar"/>
        <pathelement location="jar/jme.jar"/>
        <pathelement location="jar/jme-xml.jar"/>
        <pathelement location="jar/jme-terrain.jar"/>
        <pathelement location="jar/jme-scene.jar"/>
        <pathelement location="jar/jme-physics.jar"/>
        <pathelement location="jar/jme-model.jar"/>
        <pathelement location="jar/jme-gamestates.jar"/>
        <pathelement location="jar/jme-font.jar"/>
        <pathelement location="jar/jme-effects.jar"/>
        <pathelement location="jar/jme-editors.jar"/>
        <pathelement location="jar/jme-collada.jar"/>
        <pathelement location="jar/jme-awt.jar"/>
        <pathelement location="jar/jme-audio.jar"/>
        <pathelement location="jar/oscP5.jar"/>
        <pathelement location="jar/core.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src" excludes="**/*.launch, **/*.java"/>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="chandelier.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="Appli">
        <java classname="cj06.Appli" failonerror="true" fork="yes">
            <classpath refid="chandelier.classpath"/>
        </java>
    </target>
</project>


and i still have a problem with lwjgl not found
"no lwjgl in java.library.path "
what can i do
should i have to pass the Djava.library.path option? but where?

progress :

add "<jvmarg value="-Djava.library.path=jar/" />"

in the last target of the build.xml

now the ant generation work fine

but

the export jar still doesn't

i try to write a shell to compile this game


java -cp jar/lib/lwjgl_util_applet.jar:jar/lib/junit-4.1.jar:jar/lib/jorbis-0.0.15.jar:jar/lib/jogg-0.0.7.jar:jar/lib/jinput.jar:jar/lib/odejava-jni.jar:jar/lib/lwjgl.jar:jar/jmetest.jar:jar/jme.jar:jar/jme-xml.jar:jar/jme-terrain.jar:jar/jme-scene.jar:jar/jme-physics.jar:jar/jme-model.jar:jar/jme-gamestates.jar:jar/jme-font.jar:jar/jme-effects.jar:jar/jme-editors.jar:jar/jme-collada.jar:jar/jme-awt.jar:jar/jme-audio.jar:jar/oscP5.jar:jar/core.jar -Djava.library.path=jar -Djava.library.path=src/cj06.Appli


but i'm not sure of -Djava.library.path=jar -Djava.library.path=src/cj06.Appli

I cannot tell you what to put where in your xml files but it seemed to me there were no references to LWJGL native libraries. I do not think they are inside the lwjgl.jar.



I personally use web-start for deploying atm, and the guide tells me nicely what to do with the natives. I guess you must find a way to include the natives also.



Unless someone comes by and tells us that the problem is in something completely different :slight_smile:

yes it is clearly a LWJGL native libraries problem

i added "<jvmarg value="-Djava.library.path=jar/" />" and now my buil work but i want to deploy my application

i exported a jar of my project and now i  can run my application from the command line:

java -Djava.library.path=jar -cp jar/lib/lwjgl_util_applet.jar:jar/lib/junit-4.1.jar:jar/lib/jorbis-0.0.15.jar:jar/lib/jogg-0.0.7.jar:jar/lib/jinput.jar:jar/lib/odejava-jni.jar:jar/lib/lwjgl.jar:jar/jmetest.jar:jar/jme.jar:jar/jme-xml.jar:jar/jme-terrain.jar:jar/jme-scene.jar:jar/jme-physics.jar:jar/jme-model.jar:jar/jme-gamestates.jar:jar/jme-font.jar:jar/jme-effects.jar:jar/jme-editors.jar:jar/jme-collada.jar:jar/jme-awt.jar:jar/jme-audio.jar:jar/oscP5.jar:jar/core.jar:chandelier.jar cj06.Appli


but i still not have an executable jar!!!!

I don't think it is even possible to have an "executable jar" when using binary libraries.

On windows you could put all your required binary libraries into the jar's working directory and then "start the jar" from there, but I am not entirely sure if this works on linux, let alone mac.

Personally I prefer start scripts, it just feels better because you can organize your libraries as you like.

OPTION A:

Java library path should include ".", meaning the executing folder.

Try coping the native lwjgl files (DLL etc) to your JAR folder.

This works on almost all my installs.



OPTION B:

Put the native code in /lib/, (where / the dir is, containing your JAR file)



then create a start.bat file, containing:



//start

java -jar -Djava.library.path=./lib <YOURFILENAME>.jar

pause

//end



I distribute the whole .jar + /lib/ + start.bat for friends to try.



OPTION C:

Put the native code in your /lib/ dir (where the base dir contains the JAR file)

(Found on JAVA forum, not recommended, could break in future JDK's)

This forces the System.setProperty to take hold.


Class clazz = ClassLoader.class;
        Field field = clazz.getDeclaredField("sys_paths");
        boolean accessible = field.isAccessible();
        if (!accessible) {
            field.setAccessible(true);
        }
        Object original = field.get(clazz);
        field.set(clazz, null);
        try {
            System.setProperty("java.library.path", System.getProperty("java.library.path") + ";./lib;<project-path>/lib");
            System.loadLibrary("lwjgl");
        } finally {
            field.set(clazz, original);
            field.setAccessible(accessible);
        }


ok thank Methius for this indication but for me hevee is right i don't really need an "executable jar" for my purpose so it's ok know