Command-line compile/run quickstart

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

Command-line compile/run quickstart

pixelmike
Since this took the better part of the day to figure out, I thought I'd post what I did to get an example up and running on Windows. (Probably works with minor tweaks on other platforms as well.) This site is fairly impenetrable to noobs like me.

I didn't want to spend a lot of time figuring out Eclipse, I just wanted to try compiling and running a simple Java/OpenGL example.

(I'm assuming you know how to and have already set up the JDK on your system and know how to compile/run normal java apps, and that you have your PATH, CLASSPATH and JAVA_HOME environment variables setup.)

1. Download jogamp-all-platforms from here. Extract with 7-zip.

2. Find a simple standalone app to compile. (Harder than you'd think! The demos package download doesn't come with source. Pulling from the GIT repo was so slow it would take all day.)

Here is one:
https://github.com/sgothel/jogl-demos/blob/master/src/demos/GLInfo.java
Here's another:
https://github.com/sgothel/jogl-demos/blob/master/src/demos/texture/TestTexture.java
or browse the demos directory for something else if you prefer:
https://github.com/sgothel/jogl-demos/tree/master/src/demos

NOTE: comment out the first line:
 // package demos;
before compiling, otherwise I couldn't get the compiled classes to run.

If you download GLInfo.java to a directory with the jogamp-all-platforms directory below it, you can compile GLInfo.java with the following:

javac -cp "%CLASSPATH%;jogamp-all-platforms/jar/*" GLInfo.java

I got one warning, but otherwise it compiled ok.

Then run it with:

java -cp "%CLASSPATH%;jogamp-all-platforms/jar/*" -Djava.library.path="jogamp-all-platforms/lib/windows-i586" GLInfo

If you like using Cygwin like I do, those two lines would be:

javac -cp "$CLASSPATH;jogamp-all-platforms/jar/*" GLInfo.java
java -cp "$CLASSPATH;jogamp-all-platforms/jar/*" -Djava.library.path="jogamp-all-platforms/lib/windows-i586" GLInfo

FINALLY I can start tinkering...!
Reply | Threaded
Open this post in threaded view
|

Re: Command-line compile/run quickstart

gouessej
Administrator
Hi

pixelmike wrote
Since this took the better part of the day to figure out, I thought I'd post what I did to get an example up and running on Windows. (Probably works with minor tweaks on other platforms as well.) This site is fairly impenetrable to noobs like me.
There is a wiki, for noobs and other people. There are already some precise indications in this wiki to help people building JogAmp projects and theirs both in command line and in their IDEs (for all supported operating systems except Android):
http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE#Compile_and_run_your_project_from_the_command_line
http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE

In my humble opinion, the problem is that the page above shouldn't be named "Setting up a JogAmp project in your favorite IDE" but rather "Setting up a JogAmp project" in order to avoid the confusion you probably made. According to the title, people can assume that it contains nothing about the settings in command line.

pixelmike wrote
I didn't want to spend a lot of time figuring out Eclipse, I just wanted to try compiling and running a simple Java/OpenGL example.

(I'm assuming you know how to and have already set up the JDK on your system and know how to compile/run normal java apps, and that you have your PATH, CLASSPATH and JAVA_HOME environment variables setup.)

1. Download jogamp-all-platforms from here. Extract with 7-zip.

2. Find a simple standalone app to compile. (Harder than you'd think! The demos package download doesn't come with source. Pulling from the GIT repo was so slow it would take all day.)
There are some rudimentary examples in jogl-demos and a very simple one on the official Wikipedia page of JOGL.

pixelmike wrote
Here is one:
https://github.com/sgothel/jogl-demos/blob/master/src/demos/GLInfo.java
Here's another:
https://github.com/sgothel/jogl-demos/blob/master/src/demos/texture/TestTexture.java
or browse the demos directory for something else if you prefer:
https://github.com/sgothel/jogl-demos/tree/master/src/demos

NOTE: comment out the first line:
 // package demos;
before compiling, otherwise I couldn't get the compiled classes to run.

If you download GLInfo.java to a directory with the jogamp-all-platforms directory below it, you can compile GLInfo.java with the following:

javac -cp "%CLASSPATH%;jogamp-all-platforms/jar/*" GLInfo.java

I got one warning, but otherwise it compiled ok.

Then run it with:

java -cp "%CLASSPATH%;jogamp-all-platforms/jar/*" -Djava.library.path="jogamp-all-platforms/lib/windows-i586" GLInfo

If you like using Cygwin like I do, those two lines would be:

javac -cp "$CLASSPATH;jogamp-all-platforms/jar/*" GLInfo.java
java -cp "$CLASSPATH;jogamp-all-platforms/jar/*" -Djava.library.path="jogamp-all-platforms/lib/windows-i586" GLInfo

FINALLY I can start tinkering...!
Setting the Java library path shouldn't be necessary, you probably did something wrong. That's why I advise everyone who would like to compile JogAmp projects in command line to read the official user guide and to read this section of the wiki.

Anyway, thank you. You just want to help. If some aspects aren't clear for you, let's talk about them and we will improve the wiki together.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Command-line compile/run quickstart

pixelmike
Oh, it looks like I did miss that section of the Wiki -  I didn't scroll down far enough.

Thank you for the response and clarifications. Sorry if my post was tinged with some frustration, I just started looking into OpenGL for Java recently and am still learning how it's all put together. You can remove my post if you feel it's confusing or misleading to others.
Reply | Threaded
Open this post in threaded view
|

Re: Command-line compile/run quickstart

gouessej
Administrator
I won't remove your post and I understand your frustration. I will probably add a direct link pointing to this section into the wiki so that someone looking for a solution in command line don't believe that we only care about IDEs.

There are several really misleading and confusing posts and videos about JOGL on Internet (for example a guy used the wrong JVM with the wrong JARs, he made useless complicated things and he claimed it's our fault :s) whereas I think things are clear now about your post.
Julien Gouesse | Personal blog | Website