Need help setting up and building JOGL project

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help setting up and building JOGL project

Neil
You will have to forgive me if this is a basic question but I am struggling with this badly!

My objective ->
I want to create a project using JOGL, then build the project using ant to create a .jar that I can then run on any desktop computer (windows, linux, mac)

If it is not possible to create one .jar that can run on any OS then I will need to make 3 distributions but I think that we should be able to make one for all no?

What I have done and it is not working ->
I created a project using Eclipse, I created a libs folder and added
- gluegen-rt.jar
- gluegen-rt-natives-windows-i586.jar
- jogl.all.jar
- jogl-all-natives-windows-i586.jar

I then added these jars to the build path. Great my project now runs from Eclipse! (I'm on a Windowsx64 machine but the 32bit libs worked)

I created an ant build task, one that I have used before and built the project into a .jar file for distribution. I created the .jar and tried to run it... nothing... I ran it from cmd prompt and I see the error
- java.io.FileNotFoundException ....... gluegen-rt-natives-windows-amd64.jar

Interesting... So I was of the opinion that although my Eclipse IDE runs in 32bit my OS wants to run in 64bit. So I though tthat I could take the .jar to a 32bit machine and all would be ok... this was not the case either, I now get that it cannot find the file gluegen-rt-natives-windows-i586.jar. Very confusing.

I have looked at the 'Setting up a JogAmp project in your favorite IDE' wiki page but I cannot follow the instructions namely this bit...
- Double-click "Source attachment", type the module's source zip name, (e.g. jogl-java-src.zip for the JAR file jogl.all.jar), and click "OK".
- Double-click "Native library location", type the directory where native library files are stored, and click "OK".
And I don't know how to add these files to the class path when building with ant.

So what I need to be able to do is have a project that I can build and run :/ can someone please give me instructions on this process please?
Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

Wade Walker
Administrator
Hi Neil,

I'm not sure if the new JAR auto-loading feature (the one that loads the *-natives-*.jar files at runtime) can get them from inside another JAR. You might try putting the natives JARs beside (instead of inside) your code JAR in the same directory -- I think that's how it's supposed to work at this point.

Also, you should put both the i586 and amd64 versions of the natives JARs there, so that JOGL can pick up one or the other depending on your platform and what JVM is being used. You can't mix and match a 32-bit JVM with 64-bit natives or vice versa, so you need both types of natives JARs available to guarantee that you'll always be able to run, no matter how the user invokes your program.

I'm just starting a long vacation where I update our wiki, so I'll put up some info about how to deploy like this once I do a few experiments.
Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

Neil
Ok well this is what I am doing for now then,

I have my project which I add to a .jar file and I put this along side all the libraries and data like this

Some_arbitrary_folder
- - myproject.jar
- - jogl.all.jar
- - gluegen-rt.jar
- - gluegen-rt-natives-windows-i586.jar
- - jogl-all-natives-windows-i586.jar
- - jogl-all-natives-windows-amd64.jar
- - gluegen-rt-natives-windows-amd64.jar
- - Some_folder_for _images_etc
- - - - someimage.png
- - - - etc...

This now runs correctly so thank you.

I assume then that this being the case if I wanted all OS (mac & linux) to run the file I could simply include all these jars as well...

- gluegen-rt-natives-macosx-universal.jar
- jogl-all-natives-macosx-universal.jar
- gluegen-rt-natives-linux-i586.jar
- jogl-all-natives-linux-i586.jar
- gluegen-rt-natives-linux-amd64.jar
- jogl-all-natives-linux-amd64.jar

Seeing as all these other .jars are not very large it may be a handy way to deploy without making individual installers for each OS and architecture. Would you say that this is a good idea?

Note. I intend to stick all libs in their own folder just as soon as I figure out how lol!
Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

Sven Gothel
Administrator
In reply to this post by Wade Walker
On 03/31/2012 04:12 PM, Wade Walker [via jogamp] wrote:
>
>
> Hi Neil,
>
> I'm not sure if the new JAR auto-loading feature (the one that loads the
> *-natives-*.jar files at runtime) can get them from inside another JAR.

Yes, it would work if all JOGL JARs are in the encapsulating one in the same
path, we have a unit test for that here:

<https://jogamp.org/chuck/view/fwd/job/gluegen/536/label=linux-x86_64-nvidia/testReport/com.jogamp.common.util/TestJarUtil/testJarUtilJarInJar01/>

However, I only tested it manually with an eclipse build as follows:

https://jogamp.org/bugzilla/show_bug.cgi?id=522#c7

~Sven

> You
> might try putting the natives JARs beside (instead of inside) your code JAR
> in the same directory -- I think that's how it's supposed to work at this
> point.
>
> Also, you should put both the i586 and amd64 versions of the natives JARs
> there, so that JOGL can pick up one or the other depending on your platform
> and what JVM is being used. You can't mix and match a 32-bit JVM with 64-bit
> natives or vice versa, so you need both types of natives JARs available to
> guarantee that you'll always be able to run, no matter how the user invokes
> your program.
>
> I'm just starting a long vacation where I update our wiki, so I'll put up
> some info about how to deploy like this once I do a few experiments.
>


signature.asc (910 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

Neil
Ok well I have been playing with this today and I finally managed to get it all working.

My project is set up like this

Project
+src
++packages and classes (all my stuff)
+libs
++all the libs (12 in total)
+build.xml
+jar-in-jar-loader.zip
+SplashLogo.png

With the help of the link Sven gave and getting eclipse to save the ant build file for me to copy and modify... then finally with the help of this link

http://auralbits.blogspot.co.uk/2010/10/automating-java-application-packaging.html

I finally got everything packaged into one nice executable jar

NOTE: I don't currently have any data files for textures etc so I have not included them in the jar yet, I know that there is issues with this but I also know that it is possible so it is my next step... tomorrow, or maybe even later :S

My ant build file is below:

<project default="jar" name="Application">
       
        <property name="build" value="build"/>
        <property name="resources" value="${build}/resources"/>
        <property name="jar" value="${build}/jar"/>
        <property name="libs" value="libs"/>
        <property name="main-class"  value="com.my.MainClass"/>
        <property name="splash-logo"  value="SplashLogo.png"/>
       
        <path id="classpath">
                <fileset dir="${libs}" includes="*.jar"/>
        </path>
       
        <target name="clean">
            <delete dir="${build}"/>
        </target>
       
        <target name="compile" depends="clean">
            <mkdir dir="${resources}"/>
            <javac srcdir="." classpathref="classpath"  destdir="${resources}"/>
                <copy file="SplashLogo.png" tofile="${resources}/SplashLogo.png"/>
        </target>
       
    <target name="jar" depends="compile">
    <mkdir dir="${jar}"/>
        <jar destfile="${jar}/${ant.project.name}.jar">
            <manifest>
                    <attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
                    <attribute name="Rsrc-Main-Class" value="${main-class}"/>
                    <attribute name="Class-Path" value="."/>
                    <attribute name="Rsrc-Class-Path" value="./ gluegen-rt-natives-windows-i586.jar gluegen-rt.jar jogl-all-natives-windows-i586.jar jogl.all.jar gluegen-rt-natives-windows-amd64.jar jogl-all-natives-windows-amd64.jar gluegen-rt-natives-linux-amd64.jar gluegen-rt-natives-linux-i586.jar gluegen-rt-natives-macosx-universal.jar jogl-all-natives-linux-amd64.jar jogl-all-natives-linux-i586.jar jogl-all-natives-macosx-universal.jar"/>
                    <attribute name="SplashScreen-Image" value="SplashLogo.png"/>
            </manifest>
        <fileset dir="${resources}" includes="**/*.*"/>
        <zipfileset src="jar-in-jar-loader.zip"/>
        <zipfileset dir="${libs}" includes="gluegen-rt-natives-windows-i586.jar"/>
        <zipfileset dir="${libs}" includes="gluegen-rt.jar"/>
        <zipfileset dir="${libs}" includes="jogl-all-natives-windows-i586.jar"/>
        <zipfileset dir="${libs}" includes="jogl.all.jar"/>
        <zipfileset dir="${libs}" includes="gluegen-rt-natives-windows-amd64.jar"/>
        <zipfileset dir="${libs}" includes="jogl-all-natives-windows-amd64.jar"/>
        <zipfileset dir="${libs}" includes="gluegen-rt-natives-linux-amd64.jar"/>
        <zipfileset dir="${libs}" includes="gluegen-rt-natives-linux-i586.jar"/>
        <zipfileset dir="${libs}" includes="gluegen-rt-natives-macosx-universal.jar"/>
        <zipfileset dir="${libs}" includes="jogl-all-natives-linux-amd64.jar"/>
        <zipfileset dir="${libs}" includes="jogl-all-natives-linux-i586.jar"/>
        <zipfileset dir="${libs}" includes="jogl-all-natives-macosx-universal.jar"/>
        </jar>
    </target>
       
</project>
Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

Neil
I'll just add...

The link in the above post shows where to find the jar-in-jar-loader.zip file (it is part of the eclipse installation), we just retrieve it and place it in our project otherwise you get a BUILD FAILED error along the lines of;

C:\blah\blah\blah\build.xml:6: the archive jar-in-jar-loader.zip doesn't exist

I hope this is of use to somebody
Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

Sven Gothel
Administrator
On 04/01/2012 03:27 AM, Neil [via jogamp] wrote:

>
>
> I'll just add...
>
> The link in the above post shows where to find the jar-in-jar-loader.zip
> file (it is part of the eclipse installation), we just retrieve it and place
> it in our project otherwise you get a BUILD FAILED error along the lines of;
>
> C:\blah\blah\blah\build.xml:6: the archive jar-in-jar-loader.zip doesn't
> exist
>
> I hope this is of use to somebody
Wade will update the Wiki in regards to the new native JAR lib loading, see
https://jogamp.org/bugzilla/show_bug.cgi?id=542.
Maybe you like to contribute your scenario and ant target/macro ?

~Sven


signature.asc (910 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

gouessej
Administrator
In reply to this post by Neil
Hi

I have already done something similar, what's still wrong in your case? My Ant script even generates the JNLP files for Java Web Start, it is very easy to use.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

Neil
In reply to this post by Sven Gothel
How do you mean commit?

I can do, I have just one thing left to do however which is get my data/images folder inide the jar and working (I was going to do this over the weekend but I am currently ). Once I have that done then I can commit something else it is like giving away a horse with three legs, ok it's a horse... but it has three legs!

With regards to committing though could you please confirm what you mean? I am of course happy for people to use what I have done (else I wouldn't post it). =)

Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

Neil
In reply to this post by gouessej
Nothing is wrong anymore, I believe. What I have done is probably not the best solution but it works currently, which is a start =)
Reply | Threaded
Open this post in threaded view
|

Re: Need help setting up and building JOGL project

gouessej
Administrator
Putting everything into a single JAR is a bad approach in my humble opinion because:
- you are tempted of deploying the JAR as is whereas any application associated to the jar mime type may open it instead of running it, for example Arch on GNU Linux, WinRAR & WinZIP on Windows, etc...
- if you use it with Java Web Start, each time you have to modify a tiny thing in your fat JAR, Java Web Start will have to download it entirely. If you split your JAR into several smaller ones, Java Web Start will only download the modified JAR(s).
Julien Gouesse | Personal blog | Website