Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Store some data when JVM is active

Thread view: 
tomas - 19 Oct 2007 12:31 GMT
It is possible to store some data (very samall amount) when JVM is
active (disable) in pc ? It is situation.. I run one java application
(Swing app) few minutes leater run another application (also Swing
app) and for example applet on this same pc this same JVM and I must
store some data which the firsrt and second app (Swing) and applet can
read... I can`t use any database, file itc... So a looking for some
solution witch score data in JVM environment...  It is possible ?
Alessio - 19 Oct 2007 12:56 GMT
Not sure I understand exactly what you want... but, have you
considered using static fields ("class variables")? They're allocated
when the owning class is loaded and remain accessible for the entire
lifespan of the JVM. So different applications running inside the same
VM can access them. Of course you'll need to build an abstraction upon
such field(s), so that you can e.g. handle concurrency in a
transparent way, and in general adopt the good practice of denying
direct access to the fields, masking it with method calls.
Of course this works only if you are certain that all your apps will
run inside the same VM. If the VM is shut down, or the system crashes,
etc., any non-persistent state is of course lost.
Just my 2 cents...

cheers
Alessio S.
Lew - 19 Oct 2007 13:03 GMT
> Not sure I understand exactly what you want... but, have you
> considered using static fields ("class variables")? They're allocated
[quoted text clipped - 8 lines]
> etc., any non-persistent state is of course lost.
> Just my 2 cents...

Static variables are dangerous, albeit sometimes useful.  Some folks advocate
never exposing a static variable (except for compile-time constants and
immutable fields).

OP:  Running "one application" then "another application" implies two JVMs,
despite the phrase "same JVM".  How are you loading the second app?

You also use the term "applet", which in the Java universe means something
very, very different from "application".  Which is it?

Signature

Lew

Andrew Thompson - 19 Oct 2007 13:27 GMT
..
>OP:  Running "one application" then "another application" implies two JVMs,
>despite the phrase "same JVM".  How are you loading the second app?

My entire answer was based on the assumption that the JVM
might be 'completely shut down' between running one app. and
the other.

I think this really comes down to 'storing state between runs'
(but in this case - sharing data across different apps. as well).

>You also use the term "applet", which in the Java universe means something
>very, very different from "application".  Which is it?

I am hoping the OP mentioned applet simply to stress that
these were entirely different apps, running in (one might
expect) different VMs.  For that reason, I do not think
'static' will work for the problem (as I vaguely understand
it).

I might be completely wrong.  I did have trouble
understanding exactly what the OP meant.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Andrew Thompson - 19 Oct 2007 13:20 GMT
>It is possible to store some data (very samall amount) when JVM is
>active (disable) in pc ? It is situation.. I run one java application
>(Swing app) few minutes leater run another application (also Swing
>app) and for example applet on this same pc this same JVM and I must
>store some data which the firsrt and second app (Swing) and applet

Applets are run within a strict security sandbox unless
the code is digitally signed, and accepted by the user.
Even then, the paths that they can right/read form, might
be very limited (e.g. latest IE/Vista bug).

Do your end users really need an applet?

Applets can be launched using Java Web Start*, but
if you want something free floating, you might as
well use a (J)Frame.  

JWS apps. also get a security sandbox, but the JNLP API
allows us to 'break out' of it (with user permission), to do
things like access files**.

Even better, JWS provides the 'muffin' (like a cookie, but
for web start) that allows us to share information across
different apps. from the same codebase ('site').  This is
in the PersistenceService***.

* <http://www.physci.org/jws/#jtest>
** <http://www.physci.org/jws/#fs>
*** <http://www.physci.org/jws/#ps>
(but perhaps Sun has a better example of sharing
the muffins *between* apps)
<http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/examples.html#Pers
istenceService


>..can
>read... I can`t use any database, file itc... So a looking for some
>solution witch score data in JVM environment...  

Don't store any information within the JRE
directories themselves.

>...It is possible ?

Sure - web start is one way.

There are other ways for 'full permission' standard
desktop apps (Properties, Preferences..).

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Andrew Thompson - 19 Oct 2007 13:22 GMT
...
>Applets are run within a strict security sandbox unless
>the code is digitally signed, and accepted by the user.
>Even then, the paths that they can right/read form, ...

'write/read from' (oops!)

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

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

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.