Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  Different ways of bundling JARs  (Read 7661 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 2010-08-12 00:34:26 »

I thought I had messed up the classpath, but really it was just Eclipse sucking.

So I've got a folder of resources in my project, "data." It has "images" "fonts" and "sounds" in it. So that I can read these files from the classpath, I right clicked on the data folder and told Eclipse to include it in the build path. Happy days, everything reads from the classpath correctly as if it were in a JAR.

But I find that after doing that when I export a JAR with eclipse it puts the images and sounds directories outside of the data folder. As in, in the top level, along with bin and src, we have data, sounds, and images. And yet, inside data there is the fonts folder.

Any ideas why this is being junky? If I remove the data folder from the build path every time I export a JAR it works. But otherwise, notsomuch.

See my work:
OTC Software
Offline elias4444

Junior Member





« Reply #1 - Posted 2010-08-12 00:47:44 »

Huh, that's a strange problem. I haven't had any issues like that myself, and I use some seriously nested directories at times. Of course, I'm also an avid ANT user now and haven't used the built in jar exporter for a while.

Have you checked to make sure that they're actually folders? (Check the file view as opposed to the Java view)

Offline noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #2 - Posted 2010-08-12 01:33:46 »

I don't have folder problems with Eclipse. Ditto elias4444, I am using Ant to build my projects.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #3 - Posted 2010-08-12 01:43:03 »

Maybe I should get with the times and use Ant. Tongue

See my work:
OTC Software
Offline gouessej
« Reply #4 - Posted 2010-08-12 10:45:14 »

Maybe I should get with the times and use Ant. Tongue
You should really use it to make JARs, it just works as expected Smiley You can obviously use it in Eclipse. If you need a complete working example of use of ANT to make a JAR, create a certificate from your inputs, sign this JAR with this certificate, etc... look at the build.xml file that I use in the pre-beta version of TUER.

Offline arielsan
« Reply #5 - Posted 2010-08-12 13:41:12 »

I don't have problems with eclipse folders either. I am using Maven to build my projects (generate the jar and sign all dependencies, etc). The best thing is I can regenerate .classpath, .project and .settings with the pom.xml from Maven any time I want Cheesy.

I'm not trying to compare Maven and Ant, I am only commenting as the others which tools I use and that I don't have folder problems.

Offline lhkbob

JGO Knight


Medals: 32



« Reply #6 - Posted 2010-08-12 14:53:23 »

I believe the consensus is that you've just gone bat crazy, Demonpants  Roll Eyes

Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #7 - Posted 2010-08-12 19:51:53 »

I believe the consensus is that you've just gone bat crazy, Demonpants  Roll Eyes
Bllrrrgglggbrbrg...  persecutioncomplex

If it keeps happening then I will record it and put it on YouTube.

See my work:
OTC Software
Offline Nate

JGO Kernel


Medals: 147
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #8 - Posted 2010-08-13 06:20:38 »

You put the contents of the data directory on the classpath. When it makes a JAR, it includes the contents of the data directory, not the data directory itself. I have a directory called "resources" in my projects that contains non-source code files that will go in the JAR. In your case you would have "reources/data/sounds/eg.wav".

If you reference files in your code with "data/sounds/sound.wav", then it can work in Eclipse by finding the file on the filesystem, since the app is run out of the project folder. It may even find it from the classpath if Eclipse puts the project folder on the classpath, but I don't think it does.

Ant sucks. Stay away. Maven sucks too, even worse.

Offline CaptainJester

JGO Knight


Medals: 12
Projects: 2
Exp: 14 years


Make it work; make it better.


« Reply #9 - Posted 2010-08-13 13:30:43 »

Ant sucks. Stay away. Maven sucks too, even worse.

Never had a problem with Ant.  You especially need it with team development.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ryanm

Senior Member


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #10 - Posted 2010-08-13 14:11:40 »

Ant is useful and the de facto standard, but I hate having to edit build files. XML is an odd choice for a scripting language.
Online Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #11 - Posted 2010-08-13 14:26:24 »

Maybe I'm just ignorant, who knows, but I never really get the need for build applications. I can't stand waiting for javac to compile a huge project, why would I wait (much) longer than 1sec by using Ant?

I just write a trivial one-class-app for each project that puts all data in the correct zip/jar and looks up dependencies and whatnot.

What exactly am I missing out on?

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Nate

JGO Kernel


Medals: 147
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #12 - Posted 2010-08-13 20:50:09 »

Never had a problem with Ant.  You especially need it with team development.
Just because a tool *can* do a job, doesn't make it a good tool. Ant doesn't bring anything to team development, in fact usually makes things worse when people start copy/pasting large Ant files.

Ant is [snip] the de facto standard, but I hate having to edit build files. XML is an odd choice for a scripting language.
Perfect example of popularity having nothing to do with how good a tool is!

I just write a trivial one-class-app for each project that puts all data in the correct zip/jar and looks up dependencies and whatnot.

What exactly am I missing out on?
Absolutely nothing! I do similar, though for me it is a script. Less than 150 lines of script (including whitespace) and I can compile, JAR, sign, and create javadocs. The script is reusable across projects.

For kicks, I wrote a project to make writing my build scripts easier:
http://code.google.com/p/wildcard/
It is great for collecting paths to JAR/zip/copy/move/etc.

Online Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #13 - Posted 2010-08-13 21:24:45 »

Sounds like javascript would be a nice fit... whoever thought XML was the ultimate solution should be taken out and tickled to death.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #14 - Posted 2010-08-13 21:39:30 »

XML IS THE FUTURE!

I don't get XML. Everyone loves it, when in reality it's difficult to read and takes up more memory than it needs to. It's also slower at parsing than many other methods (not like this will be your bottleneck though). And yet people seem to (or used to seem to) poop all over the place in a frothing frenzy like this guy. I almost always used space, tab, or comma delimited text files where every line is a different element. Easier to read and better too. Or I just write bytes to a file. That's of course the best solution.

Anyway. I like the script idea. I'll just write a handy sh file to do all this shit for me. I've already got one for signing all my JARs, I might as well take it to the next level.

See my work:
OTC Software
Online Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #15 - Posted 2010-08-13 21:47:44 »


I saw the episode persecutioncomplex


Don't forget XML is great for: {0}, {1} and {2}.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline delt0r

JGO Knight


Medals: 27
Exp: 18 years


Computers can do that?


« Reply #16 - Posted 2010-08-14 11:55:00 »

XML stinks and the idea that you need a programing language to *compile* some other stuff in a different programing language is bizarre.

Look at the auto build tools. You run a tool that writes a script that is run to write make files --which then has make run on to finally run compiler and then a linker.

In java I can not use ANT and its reasonably easy to compile with a single command line. I only started to use ant when my building required the continuations asm3 task. Also i do use if for my public projects since it is a defacto tool.

But really Riven, if your not missing it, you don't need  it. 

However I do use ant tasks in eclipse for all my jar packaging now, since its easier not to forget something.


I have no special talents. I am only passionately curious.--Albert Einstein
Online Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #17 - Posted 2010-08-14 12:09:36 »

I think the copying of multiple directories into one, to zip it, is retarded. My code simply grabs the files, determines the relative paths and streams it into the JAR, warning me for duplicate entries. No file copy, no cleanup, much faster. I don't even use Java's zip classes, because calling an executable that does it for you is at least an order of magnitude quicker.

Oh well, I guess people accept delays when they are used to it. Like MSIE8 makes you wait up to 5 seconds to open a new tab. You think, 'well, it starts a whole new browser in that tab', until you see that every other browser on the planet opens new tabs instantly.

I really couldn't force myself to wait for javac, dir-copies and whatever ant does more.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #18 - Posted 2010-08-15 04:03:33 »

You might sharing this class? I'm curious to see what you did.

Like I said, I'll probably do it in unix script rather than in Java and just use the jar tool via command line, but I can see why doing it in Java would be nicer - much more flexible if you need to get complicated. Fortunately, I don't. :-)

See my work:
OTC Software
Offline Nate

JGO Kernel


Medals: 147
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #19 - Posted 2010-08-15 19:43:04 »

Did my post fix your Eclipse issues?

Here's some sample script that uses my wildcard project linked above:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
dir = "../target/projetname/jws/"
unpackedDir = dir + "unpacked/"
mkdir(unpackedDir)
packedDir = dir + "packed/"
mkdir(packedDir)

glob("deploy", "*.jnilib", "*.dylib").zip(dir + "natives-mac.jar")
glob("deploy", "*.dll").zip(dir + "natives-win32.jar")
glob("deploy", "*.so").zip(dir + "natives-linux.jar")
for (name : glob(dir, "*.jar").names) {
   print(name + ": signing...")
   system("jarsigner -keystore build/keystore -storepass password -keypass password " + dir + name + " alias")
   println("...done.")
   println()
}

glob("../target/slick", "slick.jar").copyTo(unpackedDir)
glob("../target/projectname", "projectname.jar").copyTo(unpackedDir)
glob("lib").copyTo(unpackedDir)
for (name : glob(unpackedDir, "*.jar").names) {
   print(name + ": normalizing...")
   system("pack200 -S-1 -O -E7 -mlatest " + packedDir + name + ".pack.gz " + unpackedDir + name)
   system("unpack200 -r " + packedDir + name + ".pack.gz " + unpackedDir + name)
   print(" signing...")
   system("jarsigner -keystore build/keystore -storepass password -keypass password " + dir + name + " alias")
   system("pack200 -S-1 -O -E7 -mlatest " + packedDir + name + ".pack.gz " + unpackedDir + name)
   writeText(`URI: packed/` + name + `.pack.gz
Content-Type: x-java-archive
Content-Encoding: pack200-gzip

URI: unpacked/` + name + `
Content-Type: x-java-archive`, dir + name + ".var")
   println("...packed.")
   println()
}

Offline zammbi

JGO Coder


Medals: 4



« Reply #20 - Posted 2010-08-16 16:24:13 »

I'm exporting my game to a runable jar, it takes 1 minute to load. While it takes seconds in the eclipse IDE...
I couldn't find anything on Google. Anyone have this issue before?

Current project - Rename and Sort
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #21 - Posted 2010-08-16 17:02:09 »

I'm exporting my game to a runable jar, it takes 1 minute to load. While it takes seconds in the eclipse IDE...
I couldn't find anything on Google. Anyone have this issue before?
Hm, I haven't. Do you maybe have some weird invisible files in there bogging it down, or something? Do some ls -la and have a look, maybe.

See my work:
OTC Software
Offline zammbi

JGO Coder


Medals: 4



« Reply #22 - Posted 2010-08-16 17:19:14 »

Quote
Hm, I haven't. Do you maybe have some weird invisible files in there bogging it down, or something? Do some ls -la and have a look, maybe.
I have looked inside the jar to figure out why and couldn't see a problem. Very odd issue indeed. Might be something wrong with the eclipse generated jar loading classes.

Current project - Rename and Sort
Online Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #23 - Posted 2010-08-16 18:08:03 »

Isn't it simply that now that your resources are compressed in a JAR, the JVM has to decompress them? A minute is rather lang, but if you have a few hundred JPEGs or other media files in your JAR, that can take a few more seconds.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline zammbi

JGO Coder


Medals: 4



« Reply #24 - Posted 2010-08-16 23:41:27 »

Quote
Isn't it simply that now that your resources are compressed in a JAR, the JVM has to decompress them? A minute is rather lang, but if you have a few hundred JPEGs or other media files in your JAR, that can take a few more seconds.
The Jar has only libraries and a few models/songs (less then 2 megs total). My games in the past have loaded instant even with hundreds of sprites.

Current project - Rename and Sort
Offline ryanm

Senior Member


Projects: 1
Exp: 15 years


Used to be bleb


« Reply #25 - Posted 2010-08-17 01:53:46 »

Very peculiar. Pointing visualvm at it would be the next step I suppose. Even just taking a few jstack snapshots during the startup process would probably shed some light.
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.

BurntPizza (20 views)
2014-09-21 02:42:18

BurntPizza (14 views)
2014-09-21 01:30:30

moogie (14 views)
2014-09-21 00:26:15

UprightPath (25 views)
2014-09-20 20:14:06

BurntPizza (27 views)
2014-09-19 03:14:18

Dwinin (42 views)
2014-09-12 09:08:26

Norakomi (73 views)
2014-09-10 13:57:51

TehJavaDev (97 views)
2014-09-10 06:39:09

Tekkerue (49 views)
2014-09-09 02:24:56

mitcheeb (70 views)
2014-09-08 06:06:29
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!