View Full Version : Export as Jar
rodolphe
07-18-2007, 05:40 PM
Hey!
More crazy questions :rolleyes:
I'm trying to make Pat's WW icon class (that take long/lat data from an XML, here it is : http://forum.worldwindcentral.com/showthread.php?p=45351#post45351 ) to work as a stand alone app. In Eclipse, I right-click on the package where the classes are, then "export", then "Jar file". Alright!
Then I tell him which resources to export and what's the main class.
This is supposed to make a world wind java demo that would work by itself, right?
Not in my case :eek: Here's what's happening, according to the console :
Java run-time version: 1.5.0_07
NASA World Wind Early Access 2 0.2.0
2007-07-18 12:36:03.528 java[14804] CFLog (0): CFMessagePort: bootstrap_register(): failed 1103 (0x44f), port = 0x12103, name = 'java.ServiceProvider'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2007-07-18 12:36:03.529 java[14804] CFLog (99): CFMessagePortCreateLocal(): failed to name Mach port (java.ServiceProvider)
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/glu/GLU
at gov.nasa.worldwind.PlaceNameRenderer.<init>(PlaceNameRenderer.java:29)
at gov.nasa.worldwind.layers.PlaceNameLayer .<init>(PlaceNameLayer.java:398)
at gov.nasa.worldwind.layers.Earth.EarthNAS APlaceNameLayer.<init>(EarthNASAPlaceNameLayer.java:40)
at appletrd.Carbon_main.<init>(Carbon_main.java:30)
at appletrd.Carbon_main.main(Carbon_main.ja va:172)
If somebody has an idea... :confused:
Chiss
07-18-2007, 06:19 PM
The NoClassDefFoundError seems to indicate that you are missing some stuff on your classpath. Don't forget to add the following jars to your classpath(they came with the SDK) :
gluegen-rt.jar
jogl.jar
...and also don't forget to put the .dll or .so (depending on your O/S) inside your "working directory" or the root of your packaged jar (e.g. gluegen-rt.dll, jogl.dll) or you will get an UnsatisifiedLinkError.
Hope this helps,
Chiss!
rodolphe
07-18-2007, 06:40 PM
Alright, thanks Chiss!
Alternatively : in the mean time I tried the "fat jar" plugin for Eclipse, that's supposed to put all that is needed in one resulting jar file. Here's what's happening then : every thing work great when I run it from the root directory but it doesn't work when I move the jar file to another folder (the desktop in the exemple below), here's what happens then :
...
ATTENTION: Duplicate name in Manifest: SHA1-Digest
18 juil. 2007 13:30:46 java.util.jar.Attributes read
ATTENTION: Duplicate name in Manifest: SHA1-Digest
gov.nasa.worldwind.WWRuntimeException: IO exception while parsing GeoRSS content data/sites.xml
at appletrd.Carbon_aff_sites.readXML(Carbon _aff_sites.java:253)
at appletrd.Carbon_aff_sites.<init>(Carbon_aff_sites.java:46)
at appletrd.Carbon_main.<init>(Carbon_main.java:33)
at appletrd.Carbon_main.main(Carbon_main.ja va:172)
Caused by: java.io.FileNotFoundException: /Users/rodolphe/Desktop/data/sites.xml (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at sun.net.www.protocol.file.FileURLConnect ion.connect(FileURLConnection.java:70)
at sun.net.www.protocol.file.FileURLConnect ion.getInputStream(FileURLConnection.jav a:161)
at com.sun.org.apache.xerces.internal.impl. XMLEntityManager.setupCurrentEntity(XMLE ntityManager.java:973)
at com.sun.org.apache.xerces.internal.impl. XMLVersionDetector.determineDocVersion(X MLVersionDetector.java:184)
at com.sun.org.apache.xerces.internal.parse rs.XML11Configuration.parse(XML11Configu ration.java:798)
at com.sun.org.apache.xerces.internal.parse rs.XML11Configuration.parse(XML11Configu ration.java:764)
at com.sun.org.apache.xerces.internal.parse rs.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parse rs.DOMParser.parse(DOMParser.java:250)
at com.sun.org.apache.xerces.internal.jaxp. DocumentBuilderImpl.parse(DocumentBuilde rImpl.java:292)
at javax.xml.parsers.DocumentBuilder.parse( DocumentBuilder.java:172)
at appletrd.Carbon_aff_sites.readXML(Carbon _aff_sites.java:239)
... 3 more
So the app can't find the XML data anymore, because it's looking for it in "/data/sites.xml" of whereever the jar file is executed from... :(
Here's where I put the XML file to get data from :
http://img266.imageshack.us/img266/7353/capture2bt3.png
This is how I coded it in the main class :
public class Carbon_main
{
private Carbon_main.LayerAction[] layers = new Carbon_main.LayerAction[] {
new Carbon_main.LayerAction(new BMNGSurfaceLayer(), true),
new Carbon_main.LayerAction(new LandsatI3(), true),
new Carbon_main.LayerAction(new USGSDigitalOrtho(), true),
new Carbon_main.LayerAction(new USGSUrbanAreaOrtho(), true),
new Carbon_main.LayerAction(new EarthNASAPlaceNameLayer(), false),
new Carbon_main.LayerAction(new CompassLayer(), false),
//new Carbon_main.LayerAction(new Carbon_aff_sites("carbon/sites.xml", "Sites d'Ètude"), true),
new Carbon_main.LayerAction(new Carbon_aff_sites("data/sites.xml", "Sites d'Études"), true),
new Carbon_main.LayerAction(new ScalebarLayer(), false),
//new Carbon_main.LayerAction(new Carbon_tree("carbon/SITES.xml", "Sites d'Ètude"), true),
};
So I guess I need to find a way to include this file (sites.xml) to the jar file (I think this is done) and to reffer to it in the jar, as opposed to in the folder on my computer. Any suggestion to do that? :p
Use http link if this is a Applet ( or even for Heavy client ), with URL class.
I forgot the second one.
rodolphe
07-19-2007, 08:22 PM
Cool thanks, I'm in my books figuring this out. :)
rodolphe
07-20-2007, 04:48 PM
Argh, doesn't work. My XML is really big (8mb) and it's way too slow to download everytime. Is there a way to include the xml into the jar file and call it from there? :confused:
Chiss
07-20-2007, 06:12 PM
Argh, doesn't work. My XML is really big (8mb) and it's way too slow to download everytime. Is there a way to include the xml into the jar file and call it from there? :confused:
I'm sure you can do that. Use YourClassName.class.getResourceAsStream("relative/path/inside/your/structure") or yourInstance.getClass().getRessourceAsSt ream(...) and you then hand over that InputStream to whoever is parsing the XML...
Hope this helps,
Chiss!
patmurris
07-21-2007, 02:01 AM
From IconRenderer.java
java.io.InputStream iconStream = this.getClass().getResourceAsStream("/" + path);
if (iconStream == null)
{
java.io.File iconFile = new java.io.File(path);
if (iconFile.exists())
{
iconStream = new java.io.FileInputStream(iconFile);
}
}
iconTexture = TextureIO.newTexture(iconStream, true, null);
vBulletin® v3.7.1, Copyright ©2000-2013, Jelsoft Enterprises Ltd.