Java Forum / General / December 2007
Java Web Start
Ouabaine - 15 Dec 2007 08:53 GMT Hello all,
Is there a way, from inside an application, to detect if it has been launched under Java Web Start? (in my case, I would prevent the opening of the Robot object, forbidden in the sand box).
Thanks!
Ouabaine - 15 Dec 2007 09:35 GMT > Is there a way, from inside an application, to detect if it has been > launched under Java Web Start? (in my case, I would prevent the opening of > the Robot object, forbidden in the sand box). Well, I answer to myself. I found out how to do this. I simply checks for an exception when I create the Robot class. If there is an exception, it means we are in SandBox mode. If not in normal application mode.
Andrew Thompson - 15 Dec 2007 10:50 GMT >> Is there a way, from inside an application, to detect if it has been >> launched under Java Web Start? (in my case, I would prevent the opening of [quoted text clipped - 4 lines] >an exception, it means we are in SandBox mode. If not in normal application >mode. Smart. Thanks for reporting the solution as well. (I was thinking to try and instantiate a web start service like the 'BasicService', but your solution is better, in that it tests what is actually needed).
As an aside, why the interest in the Robot? Screenshots, keyboard manipulation, what..? What is it that you were trying to offer the end user, by invoking the Robot?
 Signature Andrew Thompson http://www.physci.org/
Mark Thornton - 15 Dec 2007 11:48 GMT >>> Is there a way, from inside an application, to detect if it has been >>> launched under Java Web Start? (in my case, I would prevent the opening of [quoted text clipped - 8 lines] > like the 'BasicService', but your solution is better, in that > it tests what is actually needed). Particularly as WebStart can be used with permissions available (i.e. no sandbox). WebStart is also not the only environment that applies a sandbox.
Mark Thornton
Andrew Thompson - 15 Dec 2007 12:19 GMT >>>> Is there a way, from inside an application, to detect if it has been >>>> launched under Java Web Start? (in my case, I would prevent the opening of [quoted text clipped - 4 lines] >Particularly as WebStart can be used with permissions available (i.e. no >sandbox). WebStart is also not the only environment that applies a sandbox. Excellent points but, (completely changing the subject) are you the mthornton that started this thread?
<http://forums.java.net/jive/thread.jspa?messageID=247560>
While on that 'changed subject'.. <http://www.physci.org/jh/test.html>
Comments? Thoughts? Test result(s)?
 Signature Andrew Thompson http://www.physci.org/
Mark Thornton - 15 Dec 2007 15:42 GMT >>>>> Is there a way, from inside an application, to detect if it has been >>>>> launched under Java Web Start? (in my case, I would prevent the opening of [quoted text clipped - 13 lines] > > Comments? Thoughts? Test result(s)? Yes that was me. By own WebStart use only involves AllPermissions. All I was hoping for from that post was a common jnlp host for JavaHelp so that users didn't end up with multiple copies of the same code. Or more importantly didn't have to download the same thing for every application.
Mark Thornton
Andrew Thompson - 16 Dec 2007 01:24 GMT >> <http://www.physci.org/jh/test.html> >> >> Comments? Thoughts? Test result(s)? > >Yes that was me. By own WebStart use only involves AllPermissions. All I > was hoping for from that post was a common jnlp host for JavaHelp .. My current intent is to make an ant based build.xml which will (once paths to the JavaHelp API and a digital certificate** are set) generate a 'support page' and a *variety* of JNLPs which will provide different forms of the JavaHelp API. At first I was toying with lazy download, but is seems that will only be practical for the 'minimalist' (one jar) sandboxed version. Most versions that use 'search' etc. load the search engine using Class.forName() (or other such methods) that (given we don't have direct access to the code) make 'lazy' load impractical.
Of course, I would like to see those JavaHelp JNLP files and associated resources hosted off the dev.java.net site, for much the reasons you stated. My own physci server does not have the 'oomph' to be hosting the JH API for other sites.
** The original post stated that the JavaHelp jars are digitally signed, but the ones in the build I downloaded are not signed.
 Signature Andrew Thompson http://www.physci.org/
Ouabaine - 15 Dec 2007 15:29 GMT >>I simply checks for an exception when I create the Robot class. If there >>is [quoted text clipped - 5 lines] > keyboard manipulation, what..? What is it that you were > trying to offer the end user, by invoking the Robot? Yes both. I am making the runtime of a game creator, and some games needs to grab the desktop background. And some games need mouse movement and to position the mouse pointer.
Piet Blok - 15 Dec 2007 15:43 GMT >> Is there a way, from inside an application, to detect if it has been >> launched under Java Web Start? (in my case, I would prevent the [quoted text clipped - 4 lines] > there is an exception, it means we are in SandBox mode. If not in > normal application mode. OK,
The way I do it is as follows:
boolean webstartMode = ServiceManager.getServiceNames() != null;
Since strategies to accomplish something may depend on the fact if the application is web started, I created a class that implements strategies for both situations. This class helps me to separate those decisions from the normal application code.
Have a look at:
http://www.pbjar.org/docs/src/org/pbjar/jnlp/WebStartHelper.java
Hope this helps,
Piet
Bent C Dalager - 15 Dec 2007 16:18 GMT >"Ouabaine" <ouabaine@orange.fr> wrote in > >The way I do it is as follows: > >boolean webstartMode = ServiceManager.getServiceNames() != null; From what I remember from back when I had this problem, there are generally three different cases that you may want to distinguish between:
1) Running as stand-alone application. 2) Running in a restricted webstart sandbox. 3) Running in an unrestricted webstart sandbox.
Case (3) typically happens when you sign your webstart app and the user accepts your signature.
You solution above will not distinguish between cases (2) and (3) and so cannot be used to determine whether it is permissible to connect to arbitrary Internet addresses, etc.
As I recall, my use case was for storage of files. In cases (1) and (3) I stored them to the file system, but in case (2) I stored config data using the Persistence Service instead to avoid pestering the user with confirmation dialogs. (The storage of such state info is better kept transparent to the user.)
Cheers, Bent D
 Signature Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd powered by emacs
Piet Blok - 15 Dec 2007 17:55 GMT > In article <4763f637$0$72736$dbd4b001@news.wanadoo.nl>, Piet Blok > <p@b> wrote: [quoted text clipped - 14 lines] > Case (3) typically happens when you sign your webstart app and the > user accepts your signature. You are quite right Bent. I am just differentating between standalone and webstarted. I don't make a difference between sandboxed and unrestricted sandboxed.
And it is true that running as a standalone application is different from running as a unrestricted sandbox.
For instance, I would like to be able to control the classpath in an unrestricted webstarted sandbox. Until now, I found no means to do so, which prevents me to create a webstarted demo of some software I developed.(I need to set a local directory as the first element in the current classpath).
To explain why I like to control that classPath: my software includes a ResourceBundle Editor that enables a user to edit any existing ResourceBundle in any Locale, thus enabling a user to translate the entire JVM and any application available, and have the results be in effect immediately upon saving those bundles (without restarting the application).
Piet
Andrew Thompson - 16 Dec 2007 01:14 GMT ...
>...I would like to be able to control the classpath >in an unrestricted webstarted sandbox. Until now, I found no >means to do so, ... Control the classpath? In what way?
A trusted app. can establish an URLClassLoader to access new Jar archives - which will allow *new* classes and resources to be loaded.
 Signature Andrew Thompson http://www.physci.org/
Andrew Thompson - 16 Dec 2007 01:30 GMT ..
>To explain ... (dissmissive) Pfft! And If I'd *read* that explanation before I opened my big mouth, I might have realised an URLClassLoader would not do the job!
 Signature Andrew Thompson http://www.physci.org/
Roedy Green - 15 Dec 2007 18:24 GMT >Is there a way, from inside an application, to detect if it has been >launched under Java Web Start? (in my case, I would prevent the opening of >the Robot object, forbidden in the sand box).
see http://mindprod.com/jgloss/permission.html
You can also check to see if permission would be granted for an operation without actually attempting it and failing with an exception.
 Signature Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|