Java Web Start

O

Ouabaine

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!
 
O

Ouabaine

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.
 
A

Andrew Thompson

Ouabaine said:
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.

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?
 
M

Mark Thornton

Andrew said:
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).

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
 
A

Andrew Thompson

Mark said:
[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.

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)?
 
O

Ouabaine

I simply checks for an exception when I create the Robot class. If there
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?

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.
 
M

Mark Thornton

Andrew said:
Mark said:
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.

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)?

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
 
P

Piet Blok

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.

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
 
B

Bent C Dalager

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
 
P

Piet Blok

(e-mail address removed) (Bent C Dalager) wrote in

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 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
 
R

Roedy Green

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.
 
A

Andrew Thompson

A

Andrew Thompson

Mark said:
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.

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top