JNLP and FileOutputStream - java

I haven't done any program that utilizes Java Web Start. However, since I need to develop a program that I can automatically update remotely, I am thinking of delivering it via JNLP.
My question is, will it run given that the program uses FileOutputStream?
Before answering, I must indicate here that I cannot use an Open Dialog because I am outputting to a printer on a shared location (example: //computer/epsonlx300). Also, not very familiar with sandbox permissions, etc.
Thanks.

Unless you electronically sign your jar, it will not be able to write anywhere outside the JWS sandbox (unless the user gives permission through an open dialog). This is mostly for security reasons, but makes developing a Java Web Start app fairly frustrating.
Unfortunately since you need to write to a location outside of the sandbox, you can't use JWS unless you sign it.
For future reference, there is a JNLP service called PersistenceService that will allow you to write to the sandbox. Think of it like writing cookies, except that it's for Java Web Start apps only.

Related

I have made a JFrame which I want to put in an HTML script. (I was going to use a JApplet but it has been deprecated)

I'm using IntelliJ IDEA, I have coded a frame which I want to put into an HTML file so I can run it in my browser, how do I do this now that I cannot use JApplet? I have found this documentation: http://docs.oracle.com/javase/tutorial/deployment/webstart/deploying.html and this http://docs.oracle.com/javase/tutorial/deployment/webstart/deploying.html but I am new to programming and find this difficult to follow. I don't know for instance how I would go about putting my class files and the image that I used in a separate directory nor do I know how I go about signing my application so that it will run in a browser.
I want to put into an HTML file so I can run it in my browser,
You can use the Desktop class. This class allows you to access default applications from your desktop.
Read the section from the Swing tutorial o How to Integrate With the Desktop class for more information and working examples.
See Java Plugin support deprecated and Moving to a Plugin-Free Web.
Note that is one of my 'copy/paste comments' that does not explicitly mention JFrame based apps., however the links are still relevant in that Oracle & browser makers would not be phasing out support for applets if they wanted programmers to keep trying to shove rich client apps (e.g. Swing GUIs) into thin client web pages.
OTOH you can offer a JFrame (or a JApplet) to be launched from a link in a web page to end up free floating on the desktop of the user by using Java Web Start.
Even then, it is not a simple matter for the programmer or the end user. The programmer needs to ensure the app is digitally signed using a code signing certificate issued by a CA (usually they are expensive). The end user used to just be able to click the link, 'OK' the prompts produced by the Java virtual machine, and see the app appear on-screen. But now most browsers will download the launch file to the local file system rather than directly hand it to the JVM to be launched. So the user faces an extra step in explicitly finding the downloaded launch file and double clicking it.
This is all due to security concerns related to bugs in the plug-ins that run things in web pages. So if you were to find a way around all these hoops, please let us know. It is a security bug that requires urgent fixing.

Launch an application on button click from a web page

In my web application I need to launch a Windows application installed on client machine when a button in the page is clicked.
I know there are security policies in browsers that avoid this by default, but I also know application that do this. An example could be online meeting, web conferencing applications like WebEx or GoToMeeting.
How they do that?
I'm working with Java, so I'm wondering if Java Applets are an option to achieve this.
Is there some other well known way to solve this issue?
NOTE application execution MUST be allowed by user
The best way to deploy a Java desktop application is using Java Web Start.
And forget applets. Soon Chrome won't be able to load them (along with a number of other plug-ins) at all.
you can achieve it with applet. but user must allow to run it. it is hard to run some extern application from button or link because this is potentially danger behaviour. Remember the applet can not get access to the files on user computer and other servers (unless it is digitally signed)

Can a JNLP file be "use-once"?

We have an app that we use as an applet in our website. Since the latest Java updates, we can't use it because a third party component uses it's own applet loader, and that is being blocked by the runtime. So, we've moved to Webstart, which is working ok, but when a user downloads the JNLP then leaves our site they can access the app by loading the JNLP. So we miss out on the website traffic.
So my question is: is there any way to make a jnlp "use-once" to force a user to come back to the website? Tying it to a session variable? An entry in the database to say when they were last online maybe? Has anyone else done something similar?
Thanks in advance.
Java Web Start is a deployment technology, not a marketing strategy, but some possibilities suggest themselves:
Exploit the features of the <shortcut/> element.
Dynamically load and display site content in your application.
Make it easy to visit your site using the browse() method provided by java.awt.Desktop.

Java Applet Printing dialog won't go away

I have a simple java applet that retrieves an image from a server and prints it out. The only problem is that I get the following java security warning:
Researching on this site and all over the web, some people suggest that I sign the applet (I tried that to no avail) and others suggest that I Modify a local java security setting but that isn't feasible for my clients.
Not only do I get this warning at the start of my applet, but seemingly any time the code attempts to interact with the printer, the dialog re-appears. Also, note that there is no checkbox next to 'Always allow this applet to access the printer'. These symptoms show on any browser.
How do I get java to respect the users choice to allow it to send jobs to the printer?
You might use the JNLP API services in a sand-boxed applet in a plug-in 2 JRE. They will still prompt the user each first time they go to print, but should also put an 'always allow' check-box on the dialog (though it really only applies for that run). See a demo. of the PrintService.
See also the applet info. page that includes a link on the Next Generation in Applet Java Plug-in Technology which "..brings new abilities to applets: such as .. allowing embedded applets to gain full access to the services of Java Web Start."

Launching a java application from an URI

I'm looking for a way to launch my java application when using a custom URI.
Something in the lines of
movie://superman/
This should start my application and display information about the movie "Superman".
if friends of my have my application installed as well, i can send them that URI so they can click on it.
I used to do this back in the days in VB6 but i lost my code and forgot how to do it.
OS: windows
Any help would be appreciated.
The actual mechanism to implement this is operating-system dependent (and thus not accessible from pure Java).
The general idea is to register your application as the protocol handler for the protocol in question.
On Windows you do that by writing the appropriate registry keys
..should start my application and display information about the movie "Superman".
If you can distribute your app. from a web site, you might take a slightly different approach:
Launch the app. using Java Web Start.
In the JWS launch file (JNLP format), add a custom file extension, e.g. xuri.
Send the user an clickthis.xuri file containing the URI of interest.
When the JWS app. registered to that file type is invoked, it will be passed -open clickthis.xuri as arguments to the main(String[]).
Proceed from there..
This approach should work on any OS with 'modern' Java installed. JWS was available since 1.2, & became co-bundled with the JRE around 1.4.2.

Categories

Resources