• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How to deploy a GUI Swing application?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a GUI swing application that runs great in Eclipse. How do I distribute this to other people running Windows computers?

I know about making a JAR file, and how to use webstart to launch this from a website, however I'd like to keep it 100% localized to the user's machine.

thanks!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you know about jar files, would it be sufficient if you made it double-clickable? I.e., package everything in a single jar file, and have the app start if it is double-clicked.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Doug Nichols:
I have a GUI swing application that runs great in Eclipse. How do I distribute this to other people running Windows computers?

I know about making a JAR file, and how to use webstart to launch this from a website, however I'd like to keep it 100% localized to the user's machine.

thanks!



It sounds like you know how to do this already, then. A JAR will make it "100% localized to the user's machine". It is even convenient to make the JAR executable.

Layne
 
Doug Nichols
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

A JAR will make it "100% localized to the user's machine". It is even convenient to make the JAR executable.

Layne[/QB]



So are most people using JSmooth for this, or is there a better one that everybody likes?

danke!
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Doug Nichols:


So are most people using JSmooth for this, or is there a better one that everybody likes?

danke!



I've never heard of JSmooth before. It looks like this tool creates a .exe file that can only be run on a Windows platform. This is different from creating an executable JAR file. Executable JARs can be run on any platform that has an appropriate JVM installed. If you are interested, look at #18, 19, and 20 in our FAQ.

Layne
[ January 15, 2006: Message edited by: Layne Lund ]
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a jar file makes it convinient to run a java application by simply double clicking it. But the only problem is that it can't be executed on a system with a JRE.
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Laison:
a jar file makes it convinient to run a java application by simply double clicking it. But the only problem is that it can't be executed on a system with a JRE.



Excuse me? Did that perhaps mean any system without a JRE? I'd like to see a client-side Java desktop application that can be. If you compile from Java into native code it does not count because it is no longer Java.
[ January 16, 2006: Message edited by: Ken Blair ]
 
James Laison
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ken Blair:


Excuse me? Did that perhaps mean any system without a JRE? I'd like to see a client-side Java desktop application that can be. If you compile from Java into native code it does not count because it is no longer Java.

[ January 16, 2006: Message edited by: Ken Blair ]



I have tried it before. I created an exe file with a java exe builder. The exe will run fine on a system that has JRE on it and when you take it to another system with JRE, you will get an error or prompt say could not fine JVM. To the best of my understanding, even though you build an executable out of your java app, you still need the JRE for it to run on the designated client. Give this a try and u will c for urself.
 
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been installing java apps for years on customer's computers. On my machine, I create a directory which includes my jarfile and support jar files that aren't part of the JRE. I also include the entire JRE directory structure. Once all the resources and the JRE are included, I write a batchfile to call my jar with the localized JRE and throw it in there too.

Then I get an installation creator and bundle the whole thing up and ship it to the customer. He gets shortcuts to the batchfile placed in his start menu and/or desktop.

The major advantages of this over just using an executable jar file is that the user doesn't have to have java installed and even if they do, it doesn't matter if their version isn't the right one. You package the correct version for your app along with it and it's done. As a side bonus, many times the app is mobile as long as you keep it in the same directory structure (ie, run it from your hard drive or a thumb drive, or a CD,etc) as long as they can find the batch file and its writen to be path neutral, they can run the program.

We also do this on our hardware running linux as well. We don't use an installer, but as long as you can get your directory structure in place in a home directory it will run. Now the batch file has to be different because of the differences in how batch files are processed, and the JRE is different, but once you have the correct directory structure, batch file, and JRE, you can place that structure anywhere you have permission.

Hope this helps,
Chris
[ January 17, 2006: Message edited by: Chris Shepherd ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Laison:


I have tried it before. I created an exe file with a java exe builder. The exe will run fine on a system that has JRE on it and when you take it to another system with JRE, you will get an error or prompt say could not fine JVM. To the best of my understanding, even though you build an executable out of your java app, you still need the JRE for it to run on the designated client. Give this a try and u will c for urself.



I think you haven't built a true "exe" file then. There are programs available that will turn a JAR file into a stand-alone exe file that does not require the JRE to be installed. I haven't used any yet, so I don't know exactly how well they work.

Besides, this isn't what you wrote in your first post above. So I think you should go back and reread it and the response from Ken Blair.

Layne
 
James Laison
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Layne Lund:


I think you haven't built a true "exe" file then. There are programs available that will turn a JAR file into a stand-alone exe file that does not require the JRE to be installed. I haven't used any yet, so I don't know exactly how well they work.

Besides, this isn't what you wrote in your first post above. So I think you should go back and reread it and the response from Ken Blair.

Layne



I used exe4j from ej-technologies to create an executable for a java application but the executable will not run unless a JRE is present on the system.

If you don't mind, i will like you to tell us the java to exe builder software that converts a java application to an executable file and making the executable run without any jvm present on the system. I want you to experiment this and verify if it runs without a JRE or not.

And if it is possible to create an executable from a java app and make it run without a JRE, then you have solved a whole lot of my problems.


Chris Shepherd way of distributing his apps is quite very intelligent. Just that when someone double clicks the icon that launches the application, a command prompt window comes up because the batch file launches the program.
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Laison:


I used exe4j from ej-technologies to create an executable for a java application but the executable will not run unless a JRE is present on the system.

If you don't mind, i will like you to tell us the java to exe builder software that converts a java application to an executable file and making the executable run without any jvm present on the system. I want you to experiment this and verify if it runs without a JRE or not.

And if it is possible to create an executable from a java app and make it run without a JRE, then you have solved a whole lot of my problems.


Chris Shepherd way of distributing his apps is quite very intelligent. Just that when someone double clicks the icon that launches the application, a command prompt window comes up because the batch file launches the program.



I was said, if it needs the JVM it isn't an executable. What benefits did you gain from using it?

I am not sure what programs are available to turn java code into a true exe, but that is what google is for.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Laison:
I have tried it before. I created an exe file with a java exe builder. The exe will run fine on a system that has JRE on it and when you take it to another system with JRE, you will get an error or prompt say could not fine JVM. To the best of my understanding, even though you build an executable out of your java app, you still need the JRE for it to run on the designated client. Give this a try and u will c for urself.



I never said anything to the contrary. You did.

Originally posted by James Laison:
a jar file makes it convinient to run a java application by simply double clicking it. But the only problem is that it can't be executed on a system with a JRE.



I was asking if that was a typo and suggesting that needing a JRE isn't a "problem" (once again your words not mine) because I'm not aware of there being any way to run a desktop Java application without a JRE. A stand-alone executable created by compiling Java code into native code doesn't count because it's not really Java at that point.

I think calling the need for a JRE a problem with an executable JAR is analoguous to claiming the need for a machine is a problem with software.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chris Shepherd:
I have been installing java apps for years on customer's computers. On my machine, I create a directory which includes my jarfile and support jar files that aren't part of the JRE. I also include the entire JRE directory structure. Once all the resources and the JRE are included, I write a batchfile to call my jar with the localized JRE and throw it in there too.

Then I get an installation creator and bundle the whole thing up and ship it to the customer. He gets shortcuts to the batchfile placed in his start menu and/or desktop.

The major advantages of this over just using an executable jar file is that the user doesn't have to have java installed and even if they do, it doesn't matter if their version isn't the right one. You package the correct version for your app along with it and it's done. As a side bonus, many times the app is mobile as long as you keep it in the same directory structure (ie, run it from your hard drive or a thumb drive, or a CD,etc) as long as they can find the batch file and its writen to be path neutral, they can run the program.

We also do this on our hardware running linux as well. We don't use an installer, but as long as you can get your directory structure in place in a home directory it will run. Now the batch file has to be different because of the differences in how batch files are processed, and the JRE is different, but once you have the correct directory structure, batch file, and JRE, you can place that structure anywhere you have permission.

Hope this helps,
Chris

[ January 17, 2006: Message edited by: Chris Shepherd ]



I've had the good fortune of not having to worry too much about deployment but that may change soon, so your methodology greatly interests me. Do you deploy the entire set of libraries? I would think an optimal solution would be to include an installer that installs the executable JAR and checks for a compatible version of Java. If you could include the install bundles from Sun in your deployment the installer could install the appropriate JRE. I'm not sure how viable that is, but I don't like the idea of including the entire JRE directory structure with your application. Maybe I misunderstood what you're doing.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ken:

I deploy everything in the JRE directory plus my jar file and any other third party jar files needed for the app. I usually keep the jar files that are external to the JVM in a separate resources directory. It's probably possible to do the checks for compatibility and subsequently install the appropriate JRE, but why go through all that effort for a single standalone app? The file space needed to include the JRE(J2SE) directory is ~42MB. Thats peanuts on machines today, and even on most thumbdrives that wouldn't crimp your style too bad. My total deployment in place without the database(starts empty) is probably in the neighborhood of ~50MB by the time you include doc files and such.

Another advantage of keeping it compartmentalized is that if you need to upgrade the JRE because of new code you are passing out that needs it, you simply tell the customer he has to uninstall your old software and reinstall the new version. This doesn't affect anything else they have installed (java itself or programs that may depend on an installed version). Now doing the uninstall depends on you having used a bundled installer that registers itself for uninstalling, but I think thats fairly standard in installation makers.

If you thought you were going to be distributing more than one app, you could always reuse the same JRE for multiple programs. Just have it in a standard place in relation to all your apps. it could be one directory up from the app directorys. For example, you could make a master program directory for your company in the Program Files directory and then place your other directories like this:

c:/program files/<your company>/JRE
c:/program files/<your company>/app1
c:/program files/<your company>/app2

Then in your batch files you use to call the apps to open, you simply reference "../JRE/bin/java app1 ..blahblahblah.."

Ah well this is way too long, but hopefully it will help you get started.

Chris
 
James Laison
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is a nice thread. have learnt one or two things which has actually solved part of my deployment problems. thanks to Chris Shepherd
, Ken Blair and others.

Chris Shepherd, one thing i am trying to get straight here is, do you mean you bundle all the stuffs in C:\Program Files\Java\j2sdk1.x.x_xx manually with your application as your JRE.

It sure works, but am looking at the size which is over 40MB to be installed on a system because it wants to run an app which actual size is not more than 500KB.

May God help us all.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James: No you don't have to bundle everything that comes with the SDK. When it installs, it also includes a folder inside it called JRE. This is the same JRE you would get if you just installed the JRE on a client's machine. That folder, tho, is the one you want to copy out(copy, not move) and into your distribution folder.

Yes it is a fair size, but consider this. It would take up just as much space if it was actually installed on their machine somewhere else. Also, your 500KB program is only compiled java code and doesn't include any runtime functionality in and of itself. So the first time installation for a client has to be done by CD or downloaded from the internet, it most likely can't be mailed. The next update you put out with all those tasty improvements and bug fixes can be emailed as a small patch installer and contain only your changed jar files.

It does depend on your application and where you want the installation burden to lie. Does it fall to your users to go to the java website and download the JRE and install it before they install your program? Do you want to bear the burden of doing all the version checking on a client's machine prior to installation and then deal with bundling the JRE installer in a manageable way with your code(which will still be a big instalation file) so it all installs correctly? Or do you want the relatively clean way of sending a compartmentalized program all bundled up by itself that won't bother any other programs and places no burden on anyone except for the one small batch file that you must create to call your program with your bundled JRE. I can even provide you a sample if you need a template to work off of. Once you have the batch file made tho, there's no burden anywhere except on you to create a simple installation with the installation creator of your choice and on your user at the single point of installation where they follow your simple instructions.

Hope this helps,
Chris
 
James Laison
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i will like to see the sample code of the batch file so that i can use it as a start-off. is it possible to use the batch file to determine if JRE is already present on the system or not before installing the JRE you bundled with the installer file.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Laison:


If you don't mind, i will like you to tell us the java to exe builder software that converts a java application to an executable file and making the executable run without any jvm present on the system. I want you to experiment this and verify if it runs without a JRE or not.


I'm not sure what is available on a Windows system. However, under Linux, the gcj compiler will compile all of your Java code directly to an executable file that is essentially the Linux version of a Windows .exe file.

I'm sorry that I can't be more helpful than this. Perhaps it is the mathemetician in me that's coming out and saying "a solution exists". Unfortunately, I can't give any more details since I don't have much experience with deploying applications in this way.

Layne
 
James Laison
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chris, which installer application do u se to create setup for ur app.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chris, when you distribute the JRE it's just the libraries right? They would still need a suitable JVM and I was under the impression that it would cause compatibility issues. For example, I've heard (though I haven't checked up on it) that code compiled to 1.5 won't run on a 1.4 JVM regardless of which libraries are available. If you distribute the JVM then I'm wondering how you know which JVM to distribute since they're platform dependent.
 
James Laison
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chris, How do you check to know if a JVM is present on the client system.
 
Chris Shepherd
Ranch Hand
Posts: 286
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James:
here is a sample of a batch file (ignore newlines among the resources declaration, they are there for viewing purposes only)

The batch file lives in the same directory that contains the JRE folder.

I don't know if you could use the batch file to detect an available JRE. As far as I'm concerned, by the time I'm running the batch file, I'm assuming that my bundled JRE is already in in place. batch file creation isn't my specialty, so maybe someone else could tell you how to do it. As to your last question about how to know if a JVM is present on a client machine, I'm sure there is a simple way to detect it, but for my coding(apps only so far) I don't care. I drop mine in place and I know it's there. End of story.

I have used 3 different install maker applications. The first one was InstallShield Express. It was ok, but cumbersum at the time. I'm sure it is better now, but it's expensive to buy or upgrade. I then found a free version of InstallAnywhere 5.5 that has served our purposes nicely for the past couple years. To my knowledge, they no longer provide a free version of their software however. I keep backups of that software tucked away incase I ever need to reinstall it. I have been playing with a couple of others recently. One is called Install Creator and they have a free version you can play with if you want. A very simple one is from GatherBird (google it, you'll find it) but it didn't do enough.

Hope this gets you going.
_________________________

Ken:
No I grab the entire JRE directory which includes all the necessary libraries and binaries(java,javaw) to run for the JVM I have been coding to. I have only been distributing to clients in Windows environments, so as long as my upgrade code is done with the same JVM that I sent to a client originally, there are no compatibility issues. I do hand place code onto a linux embedded system that lives in our hardware, but once I have a single drive setup right, I just clone the disk for each new piece of hardware ordered. If I had to distribute on different platforms, it could still be done just the way I describe, only I would have to get the proper JRE flavor for the platform in question, just as you said. As far as installing it, if you can make an installer or tarball, or any form copying a directory structure and dropping it in place, then my method should work fine as long as your batch file was setup correctly for that platform(my linux batch is different from my windows batch).

Chris
[ January 20, 2006: Message edited by: Chris Shepherd ]
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chris Shepherd:
Ken:
No I grab the entire JRE directory which includes all the necessary libraries and binaries(java,javaw) to run for the JVM I have been coding to. I have only been distributing to clients in Windows environments, so as long as my upgrade code is done with the same JVM that I sent to a client originally, there are no compatibility issues. I do hand place code onto a linux embedded system that lives in our hardware, but once I have a single drive setup right, I just clone the disk for each new piece of hardware ordered. If I had to distribute on different platforms, it could still be done just the way I describe, only I would have to get the proper JRE flavor for the platform in question, just as you said. As far as installing it, if you can make an installer or tarball, or any form copying a directory structure and dropping it in place, then my method should work fine as long as your batch file was setup correctly for that platform(my linux batch is different from my windows batch).



So that means you have to distribute different installation bundles depending on platform. Hrm, well it's still pretty simple thanks for the info.
 
Always look on the bright side of life. At least this ad is really tiny:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic