What does Java Web Start Run? - java

What UI Framework does Java Web Start use? And where can I begin development for it? I'm running Netbeans but I'm fairly confused as to how Java Web Start works

JWS can launch any rich client UI framework. That means a J2SE based (J)Frame, or (J)Applet, or if you provide the necessary classes and natives on the server and specify them in the JNLP file, an SWT based UI.
Perhaps it would help to play about with some self contained JWS examples. You can find a number of them in my JNLP API demo. page, which provides a zip archive of the complete source (JNLP, .java & an an ant based build file) of each demo.
Netbeans should be able to deal with Ant based projects with ease.

Related

How to associate a file with a program in java

Take notepad for example. You can open a file with notepad (right click and open with, or double clicking on the file if it is already associated with notepad) and it will display the contents of a file. I want to be able to open an xml file with the program that I am writing so that it can do some parsing and give a desired output. What sort of ways are there to do this in java? Do I have to ask for an argument to be passed into the program when it is opened? Would this be easier in C++ or some other language? If you need any further information please let me know -- this was the best way I could come up with to discribe my situation, which may be why my google searches have come up empty. Thank you in advance for your help!
You can associate an extension with a java jar and the file name will be passed as args[0] It doesn't get much simpler than that. I suggest you try it with a "hello world" program. ;)
display the contents of a file ..What sort of ways are there to do this in java?
Install/launch the app. using Java Web Start.
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.
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 JNLP API file services (an API available to JWS apps.) that registers an interest (claims an association with) in the .zzz file-type in the launch file. Associations can also be done programmatically using the IntegrationService of the JNLP API.

Distribution of Swing application

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.

Apple Flat Package (pkg) from Java

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.

How to make a runnable JAR file that can read/write files?

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.

Build a JS server inside of Java for Google AppEngine

I just needed to create a little interface for a project. So I decided to take given code and to run it on Google AppEngine. My problem is, that I'm experienced in JavaScript and got some basic knowledge of Java, but I got no clue how a Java webapp has to be structured. I started Eclipse and installed the AppEngine-addon, downloaded Rhino and env.js (which is necessary for the bunch of code I need to run) but then found me in the situation of sitting on this files not knowing where to put them.
It would be great if someone could tell me in which directory to put which files for Rhino (I assume it's "/war/WEB-INF/lib/"), how to add the env.js-file and how to access all these files inside the .java-file which is the index of the app.
I don't know about app engine in particular, but I have had good success using Rhino jsc to compile script files which extend the Servlet API. The end result is a nice WAR file which you can deploy in any servlet container, and perhaps App Engine as well. See here for my relevant blog post about this technique, and here for a sample Eclipse project.
Have you taken a look at this tutorial on running Rhino on GAE?
It's a link from the official "Will it play in App Engine?" thread.
http://www.appenginejs.org/ may be of interest as well.

Categories

Resources