• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A primer on how IDEs make jars

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello JavaRanch,
This is a case of not quite knowing enough to know what I don't know. I'll also be reading the oracle descriptions about imports and .jars, but it's rather dense and most of it doesn't seem applicable, so I thought multitasking would be a good answer; I can put this here and hope human expertise is able to direct me more rapidly than my scrolling through dry webpages in search of wisdom. I will, of course, still be reading up in the meantime; obviously I need to learn this stuff.
I'm using JDeveloper 11.1.1.0.1. This code has gone through three iterations, environments, and programmers; I'm not sure whether that's pertinent, but just in case...
I'm making a small game. One of the parameters one can set in the starting screen is to operate a remote device (through an ADU card) whenever one scores.
It uses the javax.comm package to do so. In project properties in JDeveloper, I have comm.jar set to import, and when I dissect Game.jar, it contains comm.jar.
It runs fine as far as the first screen of the program, in which one selects program variables.
However, if I select the remote device to operate, and click "Start" to advance to the game, it doesn't respond. Not a hard crash, because I can still change variables, and even set the remote device to "off" and it will advance to the game. For further confusion, when I run it from within the JDeveloper environment, it will run with the remote device selected and the game runs fine and the remote device turns on.
Running java -jar Game.jar from the command line, when I select remote device and hit start, it throws the following error message:
... and about 50 more lines.
I've tried putting copies of comm.jar in the JRE's bin and lib folders where I hoped it would see it, I've checked to make sure it's inside Game.jar, I'm just... baffled. My intuition is that JDeveloper somehow isn't including comm.jar correctly in Game.jar, but I still don't know enough to be sure.
What else do you need? Where should I look?

And a less urgent additional question:
The program also uses two .dlls to operate. We've been dropping copies of them into Program Files/Java/jre(whatever the latest is)/bin every time we bring the jar to a new computer, which is semi-acceptable, but I was wondering if there's a way to bundle them within the .jar such that it would see them and I wouldn't have to instruct the user where to put the .dlls. For one thing, there's a small level of confusion since the jre doesn't always have the same number or location. For the second, the users sometimes get confused or lie about whether they've put the .dlls in the right place.

Happy Saint Patrick's Day!

Cheers,
Zachary
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the first part, what happens if you build it outside the IDE? Do you have an Ant or Maven script that can build it? Personally, I never rely on an IDE to build anything for me. IDEs are fine for editing, but when it comes time to build either Ant or Maven is the way to go.

For the second part, you should create an installation package for your app. That package can ensure that a JRE is installed (there are registry entries you can query), and can place the DLLs in the PATH (I recommend placing the DLLs with your JARs and adding that directory to the PATH).
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the ways to tell the difference between Java professionals and cheap labor is that a professional can - and frequently does - use an IDE to help create and debug software, but cheap labor is unable to function without an IDE. And generally a set of IDE wizards.

Needless to say, if you don't understand what you're doing well enough to do it yourself, you're likely to produce some really horrible results.

Making a JAR something you do in preparation for deployment. Many IDEs have little or no support for that end, since complex deployments require complex tools, and it's much more economical for them to pass the job on to ready-made build tools like Ant and Maven. Also, I can attest from personal experience that command-line based builds less idiosyncratic and less likely to break when the IDE goes to newer releases. And, finally, in a few cases, I've done my production builds on "headless" machines, where there was no GUI at all (GUIS are expensive resources compared to non-GUI platforms), so a command-line build was the only option.

 
Zachary Anderson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh dear... I probably qualify as a cheap labor hacker at this point. When last I did my own canning, dinosaurs ruled the earth, and I definitely haven't been staying in touch with the language.

I'll re-familiarize myself with the jar process and try it out tomorrow morning. Thanks for the brains!
 
Tim Holloway
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, we're here to help the amateurgrammers become "pro-"grammers.

Making a jar is easy, though. The jar utility is just another ZIP program that happens to support those little extra things like manifests.

Building Enterprise applications, however, has gotten a little more complicated over the years as more and more power features have become "must-have". So check out the Ant and Maven build tools. They can run the jar utility and do much more besides, giving you a "one-button" tool for assembling complex apps and doing it a lot more intelligently than something like Windows batch files would.
 
Zachary Anderson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found it! Inspired by Joanne Neal's brains on another question:
That problem was because my main class (part of a package) was at Game.jar/main.class rather than Game.jar/package/main.class.

I extrapolated that it might also be having problems finding pieces of the comm.jar because I hadn't unpacked it to Game.jar/javax/comm/(comm class files). Doing so, and re-jarring it with that directory structure, made the game able to find the remote device outside of the IDE.

I'm not sure what changed in JDeveloper's deployment options such that it doesn't seem to be including comm.jar, but as long as manual manipulation results in a working product, I'm happy .
In the meantime, I'll poke at JDeveloper a bit to see if I can get it to start including required .jars as well, so I won't have to remember to paste in these classes next time.
For more happy results, another (less-important, but still useful) function dependent on an external .jar stopped working a while back, and it stands to reason that this could be the same cause.

Off to smash more bugs!
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic