Java Forum / General / April 2007
How to do local distribution?
Patricia Shanahan - 02 Apr 2007 05:10 GMT I have a specialized Java application that is growing. Although I'm the only user, as well as the developer, I use it on several different systems. It already uses a couple of Jar files for additional packages, and I'm considering adding another one.
I would like suggestions for the best way of "distributing" it.
Currently, I manually copy the supporting Jar files to each system, and try to keep them up to date. The result of my Eclipse build process is a Jar file containing only my application class files.
Most of the systems are MS WindowsXP systems for which I am the administrator. One system is a Linux-based grid on which I am a non-root user.
Is there some reasonably convenient way I can package the application up with the right versions of the additional Jar files, so that I only have on file I need to move around.
Patricia
Mark Space - 02 Apr 2007 05:50 GMT > I have a specialized Java application that is growing. Although I'm the > only user, as well as the developer, I use it on several different > systems. It already uses a couple of Jar files for additional packages, > and I'm considering adding another one. > > I would like suggestions for the best way of "distributing" it. I suppose Java Webstart would be too obvious? Do you have a server you could leave on-line to do the update?
Andrew Thompson - 02 Apr 2007 06:06 GMT (OP wrote:)
>> I have a specialized Java application that is growing. ...
>> I would like suggestions for the best way of "distributing" it. > >I suppose Java Webstart would be too obvious? Do you have a server you >could leave on-line to do the update? Note that JWS can also be deployed 'off a diskette', though that is not something I have experimented with.
For some general web start examples, try these.. <http://www.physci.org/jws/> most of the examples at the top, concentrate on services that are only available to apps. launched using web start, but for more general apps. try the two further down that page. <http://www.physci.org/jws/#jtest> & <http://www.physci.org/jws/#giffer>
 Signature Andrew Thompson http://www.athompson.info/andrew/
Patricia Shanahan - 02 Apr 2007 06:34 GMT > (OP wrote:) >>> I have a specialized Java application that is growing. [quoted text clipped - 13 lines] > <http://www.physci.org/jws/#jtest> & > <http://www.physci.org/jws/#giffer> Do you have an example of a webstart-launchable that does not itself interact with the user and that does access local files? It would help me do a test.
One of my problems is that I need to run dozens of copies on a large grid computer, with local file access. It would be acceptable to get one security dialog the first time I run on the grid after an update. It would not be so cool if every one of the hundreds of servers in the grid displays a dialog the first time it gets one of my jobs after an update.
Patricia
Patricia Shanahan - 02 Apr 2007 06:11 GMT >> I have a specialized Java application that is growing. Although I'm the >> only user, as well as the developer, I use it on several different [quoted text clipped - 5 lines] > I suppose Java Webstart would be too obvious? Do you have a server you > could leave on-line to do the update? I had not thought about that, because the job has to run under a make variant with absolutely no user interaction but with access to local disk, and I've always thought of Webstart as being more for interactive jobs. I need to think, and read, about Webstart for batch jobs.
Patricia
Mark Space - 02 Apr 2007 06:20 GMT > I had not thought about that, because the job has to run under a make > variant with absolutely no user interaction but with access to local > disk, and I've always thought of Webstart as being more for interactive > jobs. I need to think, and read, about Webstart for batch jobs. > > Patricia Cool, I didn't know about that either. Luck of the draw, I guess.
I poked around and found this:
http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
Specifically:
Note : The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols. To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes. For example, if MyJar.jar contains another JAR file called MyUtils.jar, you cannot use the Class-Path header in MyJar.jar's manifest to load classes in MyUtils.jar into the class path.
Bummer. "To load classes in JAR files within a JAR file into the class path, you must write custom code to load those classes." So they're talking about class-path but they specifically say you need to write custom code. It doesn't look like indexing a manifest will help either.
Still, a custom classloader that looks in /lib in the current JAR... hmm, is there any way to get the filename or a handle to the currently running JAR?
Andrew Thompson - 02 Apr 2007 06:36 GMT >>> I have a specialized Java application that is growing. ..
>> I suppose Java Webstart would be too obvious? ...
>I had not thought about that, because the job has to run under a make >variant with absolutely no user interaction ... Aaah. AFAIU, JWS is not suitable for apps. with no GUI*. I could be wrong, though, it is just that the command line is invisible, and often CLI based apps. require config. parameters to be specified at run-time - to do that from within JWS would require either a JNLP launch file with each different set of parameters, or adding a GUI based prompt for those parameters.
* There's me, running off and presuming a GUI again!
 Signature Andrew Thompson http://www.athompson.info/andrew/
Patricia Shanahan - 02 Apr 2007 06:44 GMT >>>> I have a specialized Java application that is growing. > . [quoted text clipped - 12 lines] > > * There's me, running off and presuming a GUI again! I do need to specify JVM heap size, but that seems to be permitted in Webstart. In addition, each run reads one XML file and writes another, so I would need some way of specifying them. I also often use Java logging so that I can check progress while a job is running.
Patricia
Andrew Thompson - 02 Apr 2007 06:59 GMT >>>>> I have a specialized Java application that is growing. ..
>I do need to specify JVM heap size, but that seems to be permitted in >Webstart. Do you mean like.. <j2se version="1.4.2+" initial-heap-size="64m" max-heap-size="512m" /> ? (As mentioned in that third link I included)
>..In addition, each run reads one XML file and writes another, >so I would need some way of specifying them. That is the part I would use as 'half an excuse' to throw a file chooser, or the JNLP equivalent (if you do not want to sign the jar's and request full access). You can see examples of using the JNLP file service on that link form earlier.
>..I also often use Java >logging so that I can check progress while a job is running. Ummm.. not sure of any tricky caveats with that, but for the file access itself, see the earlier paragraph.
 Signature Andrew Thompson http://www.athompson.info/andrew/
Patricia Shanahan - 02 Apr 2007 07:26 GMT >>>>>> I have a specialized Java application that is growing. > . [quoted text clipped - 4 lines] > <j2se version="1.4.2+" initial-heap-size="64m" max-heap-size="512m" /> ? > (As mentioned in that third link I included) Yup, I had found something similar earlier.
>> ..In addition, each run reads one XML file and writes another, >> so I would need some way of specifying them. [quoted text clipped - 4 lines] > examples of using the JNLP file service on that link form > earlier. Wouldn't a file chooser require user interaction?
Patricia
Andrew Thompson - 02 Apr 2007 07:42 GMT ...
>>> ..In addition, each run reads one XML file and writes another, >>> so I would need some way of specifying them. ...
>> examples of using the JNLP file service on that link form >> earlier. > >Wouldn't a file chooser require user interaction? Yep. This is where I get confused though.
The other method (I can think of), that would allow setting those parameters is to have a single file that has two lines, one for the input file name, the other for the output file name. The user can edit that file by hand, and the application can use it for its configuration.
But.. I do not see how editing the config. file would be any easier for the end user than the file chooser (especially if the app. can recall earlier choices, and put the 'last file used' as the default in the file chooser)*.
* Note that is a lot easier to do with a fully trusted app., using a standard file chooser - since the JNLP based file chooser actually returns a .. javax.jnlp.FileContents ..object, which has no methods to tell the application the actual path to the file (for reasons of security, I expect). Also, the FC object is not especially well suited to being Serialized (this is based on a message I saw on the web start forum, I did not investigate further).
 Signature Andrew Thompson http://www.athompson.info/andrew/
Patricia Shanahan - 02 Apr 2007 14:36 GMT > .. >>>> ..In addition, each run reads one XML file and writes another, [quoted text clipped - 17 lines] > (especially if the app. can recall earlier choices, and > put the 'last file used' as the default in the file chooser)*. Actually, it would be because the config file generation could be automated.
Manual intervention and "last file used" are both impractical for this particular application. I often need to run big batches, sometimes over a hundred file pairs. An individual job takes from a few minutes up to about a day, and a complete batch can take a couple of days to run.
Most of the time, unless something goes wrong, I only look at gross behavior of groups of jobs, such as the number still running, and the last time one of them wrote to its log file. By the time I look at all of them individually, each job is represented by a point in an Excel chart.
Looking at the overall situation, including the unresolved security issues, Webstart does not seem quite right for this.
Patricia
Andrew Thompson - 02 Apr 2007 15:41 GMT ..
>..Looking at the overall situation, including the unresolved security >issues, Webstart does not seem quite right for this. I have to agree - it does not look like the best deployment tool for this job..
 Signature Andrew Thompson http://www.athompson.info/andrew/
Mike Schilling - 02 Apr 2007 06:53 GMT > I have a specialized Java application that is growing. Although I'm > the only user, as well as the developer, I use it on several different [quoted text clipped - 14 lines] > up with the right versions of the additional Jar files, so that I > only have on file I need to move around. I suppose that you can't share a disk among all these systems, because you'd have thought of that.
Assuming you develop on one of the XP systems, you could run a service on it that allows clients to fetch the up-to-date jar files and the name of the main class (not trivial to write, but not too difficult), and write a program that:
1. Connects to the service and write all the jar files to a temp directory. 2. Creates a URLClassLoader that access all the jars just written 3. Loads the main class and runs it
Piotr Kobzda - 02 Apr 2007 09:29 GMT > Is there some reasonably convenient way I can package the application up > with the right versions of the additional Jar files, so that I only have > on file I need to move around. There are some tools around which allows packing multiple jars into single one.
Just to point a few I'm somewhat familiar with:
* Fat Jar Eclipse plug-in (http://fjep.sourceforge.net/) which allows for jars "merging" directly from Eclipse IDE. (I've never tried it.)
* Uberjar (http://classworlds.codehaus.org/uberjar.html) -- built also into Maven -- supporting specialized class-loader for jar files packed into another jar. (Used by me a little, year, or two ago. AFIAR there were some bugs in documentation, so after reading "Manual Uberjarring" section possibly best is to explore, and if needed, slightly correct the source codes.)
* One-JAR (http://one-jar.sourceforge.net/) -- supported also by Fat Jar plug-in -- conceptually similar to Uberjar. (Never tried.)
piotr
Rogan Dawes - 02 Apr 2007 16:21 GMT >> Is there some reasonably convenient way I can package the application up >> with the right versions of the additional Jar files, so that I only have [quoted text clipped - 19 lines] > > piotr Another suggestion is ProGuard.
Recursively analyses a set of class files to identify their dependencies, including into additional jars, then constructs a single Jar containing all the required classes.
http://proguard.sourceforge.net/ IIRC
Rogan
Martin Gregorie - 02 Apr 2007 12:41 GMT > Is there some reasonably convenient way I can package the application up > with the right versions of the additional Jar files, so that I only have > on file I need to move around. Its rather a kludge, but have you considered CVS?
It can handle binarys without making a fuss about it. If you checked the JAR files into a single module a single scriptable commend could check for updates and pull changed JARs down
You could use a central repository on your Linux box with pserver configured as an xinetd task - I think there are command-line cvs versions available for all the systems you mention.
The check for updates should be sufficiently fast that you could just include it in all your runtime scripts.
 Signature martin@ | Martin Gregorie gregorie. | Essex, UK org |
Patricia Shanahan - 02 Apr 2007 14:56 GMT >> Is there some reasonably convenient way I can package the application up >> with the right versions of the additional Jar files, so that I only have [quoted text clipped - 12 lines] > The check for updates should be sufficiently fast that you could just > include it in all your runtime scripts. Interesting. On the main Linux box I have very limited privileges, and I'm only supposed to use it as a front end to the grid computer. However, I do have a subversion repository, on another machine, that I use for managing my source code.
Patricia
Martin Gregorie - 02 Apr 2007 18:38 GMT >>> Is there some reasonably convenient way I can package the application up >>> with the right versions of the additional Jar files, so that I only have [quoted text clipped - 17 lines] > However, I do have a subversion repository, on another machine, that I > use for managing my source code. I haven't used subversion, so didn't mention it.
If it can deal with binary data and has a command line interface it should be worth a quick trial.
> Patricia
 Signature martin@ | Martin Gregorie gregorie. | Essex, UK org |
Patricia Shanahan - 02 Apr 2007 19:21 GMT ...
>> Interesting. On the main Linux box I have very limited privileges, and >> I'm only supposed to use it as a front end to the grid computer. [quoted text clipped - 5 lines] > If it can deal with binary data and has a command line interface it > should be worth a quick trial. Yes to both, so it is definitely a possibility.
Patricia
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|