1

Is it still possible to start a 'native' application under windows via a java applet in a browser? IE "Click here to start notepad.exe" on a web page. The most recent reference I could find for this was dated 2002. Im wondering if this model / concept is no longer supported.

4
  • 2
    did you try the approach you found? did it work? Commented Jun 2, 2011 at 14:44
  • Its so old that some of the packages aren't available anymore. Getting it to build was beyond me. Commented Jun 2, 2011 at 14:46
  • here is an IE solution: codereflex.net/how-to-run-exe-on-webpage --> I need something browser neutral though. Commented Jun 2, 2011 at 14:50
  • 1
    Java can certainly do it.. now I just need to remember how to write an applet.. Commented Jun 2, 2011 at 14:59

3 Answers 3

9

Yes, but the applet has to be signed.

Signed applets will prompt the user to give them permission. Once given, the applet has the same rights as any application running on the machine, including the ability to launch native apps (or link native libraries, which I've had to do in the past).

Sign up to request clarification or add additional context in comments.

3 Comments

This worked fine. I was overthinking it. Self-signing does make for a popup that needs to be explained "no really - you can trust me" but that's doable.
Is there a good way to bundle the native lib so that it gets downloaded onto the user's hard drive? What path should you use when you call System.loadLibrary()?
I believe you can include it in your jar file, but I haven't tried that (we had the applet download it on the fly so it could pick up updates to the dll).
2

..Is it still possible to start a 'native' application under windows via a java applet in a browser?

Sure thing. As mentioned in other replies, a signed (and trusted) applet can use Runtime.exec(String) to launch a native application.

As of Java 1.6, it becomes simpler with the implementation of Dekstop.getDesktop.open(File), which will open the selected File with whatever application the OS has registered as a consumer for that file type.

As of Sun's Plugin2 architecture (1.6.0_10+ in a Sun/Oracle JRE) offers a more generic method for an (sand-boxed) applet embedded in a web page, using the JNLP API's BasicService. Here is my demo. of the BasicService

4 Comments

Didn't know about the Desktop stuff (haven't had a chance to use 1.6) Can you do do the Desktop.open() method on an exe to launch it? And does that work in unsigned applets, or does it still need to be signed?
@Herms: An applet needs to be trusted to use the methods of the Desktop class.
The BasisService still does not offer starting a native application, does it? Or do you use a file: URL to run a local application?
@Paŭlo Ebermann: You are correct, but the BasicService can be used to launch JWS based desktop applications.
0

The portable way of doing this is to create a signed Applet.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.