JVM and java application

  • Follow


If there are several java applications/programs running on the same
machine, are these java applications/programs using their own JVMs or
are they share the same JVM?

Thanks.
0
Reply junw2000 (221) 1/25/2010 3:56:59 AM

On 1/24/2010 7:56 PM, Jack wrote:
> If there are several java applications/programs running on the same
> machine, are these java applications/programs using their own JVMs or
> are they share the same JVM?
>
> Thanks.

Each time you start a Java app, you create a new JVM.  That's not to say 
that you can't have a Java program that loads other Java programs if you 
want them run on the same JVM.  I don't know what the state of things is 
in browsers for sure but I would suspect that every applet that is 
loaded gets its own JVM.

-- 

Knute Johnson
email s/nospam/knute2010/

0
Reply Knute 1/25/2010 4:10:01 AM


Knute Johnson wrote:
> On 1/24/2010 7:56 PM, Jack wrote:
>> If there are several java applications/programs running on the same
>> machine, are these java applications/programs using their own JVMs 
>> or
>> are they share the same JVM?
>>
>> Thanks.
>
> Each time you start a Java app, you create a new JVM.  That's not to
> say that you can't have a Java program that loads other Java 
> programs
> if you want them run on the same JVM.  I don't know what the state 
> of
> things is in browsers for sure but I would suspect that every applet
> that is loaded gets its own JVM.

Web servers and application servers, in general, run all of their 
applications in a single JVM (or perhaps a replicated set of JVMs, 
each of which can run any of their applications.) 


0
Reply Mike 1/25/2010 6:17:03 AM

According to Jack  <junw2000@gmail.com>:
> If there are several java applications/programs running on the same
> machine, are these java applications/programs using their own JVMs or
> are they share the same JVM?

It fully depends on what you mean by "JVM".

At the source code level, two applications or applets are deemed
distinct if they "do not see each other": the classes defined in one
application are not visible from the other, and both applications may
have identically-named classes. Since Java applications are isolated
from system and hardware, that lack of visibility is all that makes
sense from the application point of view.

From the outside, things are more complex. Let's assume for now that the
JVM is launched as the 'java.exe' (Windows) or '/usr/bin/java' (typical
Linux) executable. Then the application runs in its own JVM instance,
i.e. a single process with its address space, separated from the other
processes by way of the operating system facilities. Still, the
executable code comes from files, which are not duplicated (you may run
several applications from the same executable), and the in-memory copy
of executable code may be shared between several concurrently invoked
Java application. This happens under the hood, and is invisible to
applications, except that sharing saves memory and thus improves
performance. On that subject, it is worth noticing that a Java
application involves a rather small chunk of pre-compiled native code,
and a bulk of dynamically translated bytecode; the in-memory sharing of
executable code by the OS can be performed only on the native code.

Another possibility is integrating the JVM in a bigger application, and
calling it through JNI. This involves calling JNI_CreateJavaVM(). There,
several Java VM "instances" may coexist within the same address space.
They still do not see each other, as if they were in separate processes,
but from the OS point of view they are a unique process. The native code
is shared in RAM.


	--Thomas Pornin
0
Reply Thomas 1/25/2010 1:49:09 PM

On 25-01-2010 01:17, Mike Schilling wrote:
> Knute Johnson wrote:
>> On 1/24/2010 7:56 PM, Jack wrote:
>>> If there are several java applications/programs running on the same
>>> machine, are these java applications/programs using their own JVMs
>>> or
>>> are they share the same JVM?
>>
>> Each time you start a Java app, you create a new JVM.  That's not to
>> say that you can't have a Java program that loads other Java
>> programs
>> if you want them run on the same JVM.  I don't know what the state
>> of
>> things is in browsers for sure but I would suspect that every applet
>> that is loaded gets its own JVM.
>
> Web servers and application servers, in general, run all of their
> applications in a single JVM (or perhaps a replicated set of JVMs,
> each of which can run any of their applications.)

Java EE has a different application concept than Java SE.

Seen from Java SE perspective the app server is the app
and the ear's are plugins.

Seen from Java EE perspective the ear's are multiple apps.

Arne

0
Reply ISO 1/26/2010 1:05:16 AM

On Sun, 24 Jan 2010 19:56:59 -0800 (PST), Jack <junw2000@gmail.com>
wrote, quoted or indirectly quoted someone who said :

>If there are several java applications/programs running on the same
>machine, are these java applications/programs using their own JVMs or
>are they share the same JVM?

logically they each have their own JVM, unless you use Echidna.
See http://mindprod.com/jgloss/echidna.html

However most of the JVM on windows is implemented with DLLs which is
shared code.  So you have shared code and separate heaps for data.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Don�t be discouraged by a failure. It can be a positive experience. Failure is, in a sense, the highway to success, inasmuch as every discovery of what is false leads us to seek earnestly after what is true, and every fresh experience points out some form of error which we shall afterwards carefully avoid. 
~ John Keats (born: 1795-10-31 died: 1821-02-23 at age: 25)
0
Reply Roedy 1/26/2010 6:42:38 AM

On Mon, 25 Jan 2010 22:42:38 -0800, Roedy Green
<see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted
someone who said :

>
>logically they each have their own JVM, unless you use Echidna.
>See http://mindprod.com/jgloss/echidna.html
>
>However most of the JVM on windows is implemented with DLLs which is
>shared code.  So you have shared code and separate heaps for data.

Even though they share code, the who JVMs  are not aware of the
existence of the other.  

OS puts code in read-only, thus shareable memory. It puts data is
separate read-write memory.

The RAM hardware is identical. It is just the memory addressing
hardware is told to block writes to parts of RAM containing code.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
Don�t be discouraged by a failure. It can be a positive experience. Failure is, in a sense, the highway to success, inasmuch as every discovery of what is false leads us to seek earnestly after what is true, and every fresh experience points out some form of error which we shall afterwards carefully avoid. 
~ John Keats (born: 1795-10-31 died: 1821-02-23 at age: 25)
0
Reply Roedy 1/26/2010 10:07:25 AM

6 Replies
300 Views

(page loaded in 0.385 seconds)

Similiar Articles:













7/24/2012 7:40:34 AM


Reply: