I want to distribute a swing app to my client. In that application two property file are there, which should be visible to client so that they can edit, I can not give it as runnable jar. Also I want something like apache-tomcat zip file which once you extract it will arrange folder structure also will give property file to edit and on next run it reads that property. Also apache-tomcat starts with startup.bat or startup.sh like that I also want.
Use Java Web Start to install and update the application.
User editable properties
Put them in (a properties file in) the Jar
When you go to check for the properties, do so using the PersistenceService. If they do not exist, read them from the text file in the Jar, and put them there. Here is a demo. of the service.
When the user wants to see/edit the properties, show them via a JOptionPane.
Desktop integration
JWS offers desktop shortcuts and menu items to launch apps., when supported by the platform, as well as an API to install and remove them (see the IntegrationService). Much slicker than batch files!
Currently we are using GetDown to handle distribution of our swing applications. We use Tomcat to distribute updates and GetDown to download those updates. It's really flexible and powerful, and much better than java WebStart.
A good tutorial : http://www.hascode.com/2012/05/creating-updatable-java-applications-using-getdown-and-the-getdown-maven-plugin/
Project website : http://code.google.com/p/getdown/
If I understand you correctly you want a tool to make distribution package for your application. That generates folder structure and unpacks application and data files to this structure.
There are many free and commercial setup builders. I think you would prefer multi-platform builder, so look for java setup builder.
Check this thread, this question was discussed there.
Related
I have an application that has an applet that does two simple things:
Download an executable jar file from our server (if the user doesn't already have it) to an specific folder in the user's PC
Execute the jar file with the corresponding parameters
This jar file monitors an Office file for changes and send it back to our server.
The problem is the war Chrome is creating with Java with this NPAPI thing. So I have until September to think of an alternate technology or stop the Chrome support.
Do you think of some other way to achieve the same result? Just download and execute. Doesn't seem that hard =(. Can HTML 5 do that?
EDIT
I was looking into Java Web Start and became a little happy. It appears that it can do what I want: executing a up to date jar file passing parameters. But I never worked with JWS, so I have some doubts:
Is it possible to pass parameters to it? I read about some JSP files that you can configure to do that, but I'm still unsure.
Theoretically, it should start automatically from a browser link, am I right? I tried this site:
https://docs.oracle.com/javase/tutorial/deployment/webstart/running.html
and it didn't work that way. I had to mark "always open files of that type" on Google Chrome. Is there a way for automatize it?
Thanks again!!
From what I know there are at least two things that allow you to stick with Java.
Webstart
Install4
Webstart is provided by Oracle and allows you to download Java program from the web and execute them. Update mechanisms exist, so you can always provide a current version.
Install4J (or any other installer for Java applications that offers an update mechanism) provides an installer which enables your customer to install an application which afterwards will be kept up to date by the integrated update mechanism. But Install4J comes at a price, there might be freeware / open source alternatives. Install4J and its alternatives are often discussed here on SO, you might want to check here.
I think the FileAPI of HTML5 is limited and can not access arbitrary files because a sandbox prevents this. You might check SO again for details about that.
I want to know how to make a java program that can be used to open stuff up. Ex: notepad++, win zip.... Do I have convert the jar to .exe first? Also, does the file chosen get passed in to String[] args?
By the way, I know that it works with cmd but thats not what I'm asking.
Depends on the OS. Under windows, you need to attach some details into the registry.
Have a look at the 3rd answer in Utilising a file association in a Java application for an example?
You could also have a look at http://www.rgagnon.com/javadetails/java-0592.html
UPDATE
Also, when the OS executes the program, you should receive the file as a command line parameter through the main method
I don't know if this will work suit your needs or not, but you could also take a look at File association in Mac
There's many choices on how to make a Java program runnable. Like you mention, the simplest choice is to use the command line. If you want to make it work with most OS's GUI interfaces (and the Open With dialog) the easiest choice is to make an executable jar. IDEs can make this very easy for you, in Eclipse just right-click on the project and select Export > Java > Runnable JAR file.
Another excellent option is to turn your application into a Java Web Start application, which lets users easily run Java programs being served up online.
Alternatively, like you mention, you could convert it into an .exe file:
Compiling a java program into an executable
How do I create an .exe for a Java program?
How can I convert my Java program to an .exe file?
Deploy the app. using Java Web Start.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
Here is a demo. of the file services in which the app. is associated with the file type .zzz.
..does it get passed via the windows file chooser?
No. It gets passed to the main as either -open filename or -print filename. What the app. does with those strings is up to it. The demo. linked above will prompt the user in the sand-boxed version, simply because it is sand-boxed. The other one should work without showing prompt or dialog.
I've been doing some research into how to make Apple flat packages from a Java webapp. There doesn't seem to be much out on the subject. I found a website that details the contents of a flat package but it seems like a bit of a project to start from scratch. Anyone have any experience building PKGs? Does anyone know of any libraries to aid in the process?
EDIT:
It seems I may not have been clear in my request. My goal is to have users go to a website that requires them to enter some information. After they've entered their information my code would create a PKG for them that contains some information about them. For example, maybe the postinsall script would run the command "say 'Hello USERNAME_THEY_ENTERED'". Silly example but it's the general idea. The user would then be able to run the PKG and the install that takes place would be customized with their information.
Why would you want a web application in a pkg file? What servlet container accepts pkg files?
Web applications are meant to be packaged as WAR or EAR files (since we are talking about Java) and to be deployed on a servlet container like tomcat, jetty, websphere, glassfish, jboss, ... running on a server. The client computer then uses a browser to access to web application on the server.
PKG files can be compared to MSI files. These are meant to facilitate the installation of software (or libraries) on a client. For that the website you linked seems to have valid information.
I am not sure why you want to do that for a webapp but we have done it for a standalone Java App (which actually was a collection of webapps including the server).
If this works for you, try to prepare your application.app folder using jarBundler. It provides an Ant task that will make things much easier.
If this does not work for you (as unfortunately was the case for us), then you have to prepare the application.app folder by hand and script adding the java resources. Start from an existing app, generated with Jar Bundler for instance, and adjust accordingly.
Then you need to install XCode and get PackageMaker. This app has a GUI but you really need to read the doc. The biggest issue we have met is that you cannot script the package build process.
I need to add that, unless you need to run some post-install scripts, building a DMG is probably much easier.
I have created a Java software with a graphical interface using SWING. I have packaged it in a runneable JAR file by using he "export" function of ECLIPSE and it runs fine on my computer.
However, the function of reading files of my software does not work on some other computers.
I guess that it must be a security permission problem.
So my question is: how to give the permissions to my Jar file or how the user can give the permissions so that my software is allowed to read file?
I'm looking for something as simple as possible as i'm not going to sell my software.
EDIT: My application is a desktop application (not an applet).
Thanks,
Digitally sign the Jar.
Create an XML based (JNLP) launch file for it.
Launch it from a link using Java Web Start. JWS can install desktop shortcuts & menu items for it, if requested in the launch file and supported on the target OS.
I'm looking for something as simple as possible..
Installing applications in a way that is reliable & simple for the end user, is not easy for the developer.
I took the advice I've been given here to look at IzPack to create a JNLP based one click installation for computer illiterate clients who are using a Java desktop application I've created.
Java Web Start Driven Installation
However, I can't seem to find my way around it.
I don't know where to begin and seems the online tutorials are basic "look at the examples" which are themselves pre compiled and not sourced.
I want to create a simple form - be it in JSP or the JNLP install app (preferably JSP and the JNLP should get arguments from the JSP that launches it).
Then when the users click Install, the program installs to the default directory of userappdata with no questions (except for the UAC).
But IzPack seems to be forcing me to use panels and stuff... Not sure I want all of that.
Or maybe....
Hmmm, writing this just gave me an idea, but I'd still like some feedback.
Thanks.
Another approach perhaps?
If all what you need is to allow the user invoke a JAR, then consider using JSmooth to wrap it in an exe file. The exe file knows how to invoke java correctly and prompt the user to download if not present.
We also have used one-jar to wrap multiple jars in a single jar for exactly this purpose.