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.

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)

You should really use it to make JARs, it just works as expected 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.

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 .

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.

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.

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!

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.

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.

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

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!

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. :-)

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!

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.

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