Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Help with JAR and JNLP  (Read 1995 times)
0 Members and 1 Guest are viewing this topic.
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Posted 2008-04-14 02:51:27 »

Hey guys –

I've got a project that uses LWJGL, and I keep trying to create an executable JAR file (so I can make a JNLP), but executing the file always fails. I've got the manifest with the main class specified, and I've even tried to have Eclipse do it automatically with the same results. I think the problem is that while working in Eclipse, it automatically includes the workspace in my class path, and therefore the LWJGL JARs and dylib's are all included in the path. When I make a JAR, however, it seems even to ignore everything within the JAR as part of its class path (I have the JARs and the dylibs inside the folder for the JAR file I am building).

So how can I specify the class path correctly so that it includes everything within its own directory? I tried just a slash, but that does nothing.

1  
2  
Main-Class: Agent00PK
Class-Path: /


The above was one attempt at a manifest, another was without the "Class-Path" part. I also tried creating a containing folder called "Agent00PK" and making that the class path, but that didn't work either. I seem never able to get the class path working at all. Do I need to specify containing folders as well?

Help, please!
Thanks.

PS – Even though I've been programming in Java for 5 years, I have simply dealt with not knowing how to do this by putting the JARs into my Java Extensions folder. I'd love to finally learn how to get this working.

Ah... I couldn't find the error reports, but I finally located them (the new OS X puts them in subfolders).
1  
2  
Apr 13 19:58:40 computer [0x0-0x4d24d2].com.apple.JarLauncher[10557]: Exception in thread "main" 
Apr 13 19:58:40 computer [0x0-0x4d24d2].com.apple.JarLauncher[10557]: java.lang.NoClassDefFoundError: Agent00PK

See my work:
OTC Software
Offline cylab

JGO Ninja


Medals: 52



« Reply #1 - Posted 2008-04-14 07:23:15 »

You have to put the relative locations to all your dependencies in the Class-Path section. And by the way, don't put things in the default package:):
1  
2  
Main-Class: <your-package>.Agent00PK
Class-Path: ./lib/lwjgl.jar ./lib/jinput.jar <etc.>


But be aware that you cannot specify native code locations for an executable jar. The only way I know of is to deploy the .dll files beside the main jar, and this does only work for windows. Since you are not after local deployment but webstart, this probably doesn't matter.

You might also want to take a look at this: http://www.cokeandcode.com/webstarthowto

Mathias - I Know What [you] Did Last Summer!
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #2 - Posted 2008-04-14 07:43:12 »

Smiley I started with Kev's tutorial but couldn't get the classpath part to work when making my JAR file, so I couldn't get anywhere beyond that.

If I can't specify native code locations, how would I ever do that without Webstart? I also have a question about packages. I do have some packaged stuff in my program (and non-packaged stuff), so when creating my initial JAR, does it automatically search through all containing folders for any .class files, or do I need to specify every single folder within the command line? Like if I have:

net/stuffa/*.class
net/stuffb/*.class

etc.

If I just have it include the net folder will it get everything within?

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cylab

JGO Ninja


Medals: 52



« Reply #3 - Posted 2008-04-14 08:08:02 »

If I can't specify native code locations, how would I ever do that without Webstart?

I am afraid you have to write a starter script for that...

I also have a question about packages. I do have some packaged stuff in my program (and non-packaged stuff), so when creating my initial JAR, does it automatically search through all containing folders for any .class files, or do I need to specify every single folder within the command line? Like if I have:

net/stuffa/*.class
net/stuffb/*.class

etc.

If I just have it include the net folder will it get everything within?

Don't know since I am using ant to create my jars. I am afraid you have to read the jar documentation http://java.sun.com/j2se/1.4.2/docs/tooldocs/tools.html Tongue

Mathias - I Know What [you] Did Last Summer!
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #4 - Posted 2008-04-14 08:20:11 »

Okay, well I got Eclipse to make a JAR that at least executes if I put LWJGL in my Java Extensions, which is fine for now. The real issue at this moment is modifiability. In order to export everything as a JNLP, it's got to be in a JAR. That means my Levels folder does as well, and my program includes a Level Editor that is supposed to allow you create your own levels. If you're working using directories, that's not a problem at all because you can just make a new .lvl file in the Levels folder, but when I have to bundle the Levels folder that creates issues. Similarly, save files pose a similar problem.

As such, do I need to have two places to look for levels, one in the JAR, and one on the local disk? It just seems way too difficult for the user to do much, then. They especially can't modify the level files I created and put in the game, which I was hoping they could do.

Is there any way to make a JNLP have directories as well? I'm thinking maybe I'll have my actual program load levels from a web site, but that's still pretty annoying to have to do.

See my work:
OTC Software
Offline cylab

JGO Ninja


Medals: 52



« Reply #5 - Posted 2008-04-14 08:40:19 »

Resource files for java webstart applications should be in a jar to make the application selfcontained and can be run unsigned. If you sign your app (and you might have to anyway because of lwjgl natives), you could just create a folder on the local disk (preferable using FileSystemView.getFileSystemView().getDefaultDirectory()+"/<your app name>" which resolves to "<My Documents>\<your app name>" on windows and "<user.home>/<your app name>" on linux) and unpack the levels on the first application start.

Another note on putting something into the java extensions folder: don't do it! Chances are that you are breaking java webstart applications that use lwjgl as well. And more importent - you can't test if your jnlp is correct as long as you have lwjgl there, because the files from the ext folder are always loaded regardless of the jnlp settings.

Mathias - I Know What [you] Did Last Summer!
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #6 - Posted 2008-04-14 08:59:32 »

Resource files for java webstart applications should be in a jar to make the application selfcontained and can be run unsigned. If you sign your app (and you might have to anyway because of lwjgl natives), you could just create a folder on the local disk (preferable using FileSystemView.getFileSystemView().getDefaultDirectory()+"/<your app name>" which resolves to "<My Documents>\<your app name>" on windows and "<user.home>/<your app name>" on linux) and unpack the levels on the first application start.

Another note on putting something into the java extensions folder: don't do it! Chances are that you are breaking java webstart applications that use lwjgl as well. And more importent - you can't test if your jnlp is correct as long as you have lwjgl there, because the files from the ext folder are always loaded regardless of the jnlp settings.
Yeah, I know not to put stuff in extensions, but if it's the only way to see if my JAR works, I do it temporarily. Don't worry, I just took them out as soon as I finished. Smiley

See my work:
OTC Software
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #7 - Posted 2008-04-14 10:00:05 »

Okay, I've almost got it.  Cheesy

Just one last problem. In Kev's example, his nativelib's are JAR files. I figured this was just in his case, so I substituted those with the library files.

ex:
<nativelib href="lib/jogl-linux-native.jar"/>
becomes
<nativelib href="libjinput-linux.so"/>

I got an error saying that my .so was a corrupted JAR file... because it's not a JAR file. How do I get it to read in the libraries instead of a JAR? Or do I need to package all the libraries into a JAR and use that?

See my work:
OTC Software
Offline cylab

JGO Ninja


Medals: 52



« Reply #8 - Posted 2008-04-14 10:14:48 »

The natives have to be packaged in jars. Just put all .so/.dll/.jnilib files in a jar for the appropriate platform and reference the jar.

Mathias - I Know What [you] Did Last Summer!
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #9 - Posted 2008-04-14 10:22:22 »

Okay, cool, I've done so. Now I'm waiting for the JAER signer, because apparently I have to sign all of LWJGL's stuff as well. Annoying!

[EDIT]
Woohoo! We have success!

Boy-o did that take a long time.  Shocked

See my work:
OTC Software
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cylab

JGO Ninja


Medals: 52



« Reply #10 - Posted 2008-04-14 10:30:32 »

Seems like you don't have to... There is an jnlp extension available:

1  
    <extension name="lwjgl" href="http://lwjgl.org/jnlp/extension.php" />


I just looked into the jnlps linked on the lwjgl demo page Smiley

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
<!-- JNLP File for LWJGL Demos --> 
<jnlp
  spec="1.0+"
  codebase="http://lwjgl.org/jnlp/"
  href="lwjgl-demo.php/test.input.TestControllers">
  <information>
    <title>LWJGL Demo [test.input.TestControllers]</title>
    <vendor>LWJGL</vendor>
    <homepage href="http://lwjgl.org/"/>
    <description>Demonstration of LWJGL</description>
    <description kind="short">Technology Preview</description>
    <icon kind="splash" href="logo.png" />
    <offline-allowed/>
  </information>
  <resources>
    <j2se version="1.4+"/>
      <jar href="lwjgl_test.jar"/>
    <jar href="lwjgl_media.jar"/>
    <extension name="lwjgl" href="http://lwjgl.org/jnlp/extension.php" />
  </resources>
  <application-desc main-class="org.lwjgl.test.input.TestControllers">
    </application-desc>
</jnlp>

Mathias - I Know What [you] Did Last Summer!
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #11 - Posted 2008-04-15 01:49:37 »

Seems like you don't have to... There is an jnlp extension available:

1  
    <extension name="lwjgl" href="http://lwjgl.org/jnlp/extension.php" />


I just looked into the jnlps linked on the lwjgl demo page Smiley

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
<!-- JNLP File for LWJGL Demos --> 
<jnlp
  spec="1.0+"
  codebase="http://lwjgl.org/jnlp/"
  href="lwjgl-demo.php/test.input.TestControllers">
  <information>
    <title>LWJGL Demo [test.input.TestControllers]</title>
    <vendor>LWJGL</vendor>
    <homepage href="http://lwjgl.org/"/>
    <description>Demonstration of LWJGL</description>
    <description kind="short">Technology Preview</description>
    <icon kind="splash" href="logo.png" />
    <offline-allowed/>
  </information>
  <resources>
    <j2se version="1.4+"/>
      <jar href="lwjgl_test.jar"/>
    <jar href="lwjgl_media.jar"/>
    <extension name="lwjgl" href="http://lwjgl.org/jnlp/extension.php" />
  </resources>
  <application-desc main-class="org.lwjgl.test.input.TestControllers">
    </application-desc>
</jnlp>


Well that's good to know.

Thanks for all the help, cylab, it's been, well, very helpful.

See my work:
OTC Software
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (33 views)
2014-10-17 03:59:02

Norakomi (25 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (74 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!