Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What is the function of JRE ????? and Strings???

 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i thought JRE is only for running applets...........
but yesterday i was asked some other use or pupose of JRE........

1.so What is the fuction of JRE???

have one more question....plz take it separately:



2. When we write sth like:
String s = new String("Test");

i know that in such a case the JVM creates 2 objects, both in the heap, one having handle in String Constant Pool and other having handle in some other table(eg: Local Variable table).
I have an understanding regarding how this happens, i'll explain it hereunder, i would be greatful to you all if you can analyse mine, and correct me where i go wrong.....

So here i go...
whenever we have such a piece of code, and as soon as the class containing this is loaded, first of all all static content will get initialized. After initialization JVM will skim through the byte code for presence of String Literals. As soon as it finds one, it will create an object in the heap and a reference will be there in String Constant pool. Now when the block or the method containing that line of code(String s = new String("Test") is executed a new object is created in the heap.

this is my understanding....

Plz treat both ques. separately.......Confused about purpose of JRE also
 
Rahul Bhosale
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it true that to run an applet it requires a JRE but thats a plug-in.

To run any Java program, (JSPs,Servlets, Talibs, EJB, Swing etc) require a JRE.
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The acronym JRE stands for Java Runtime Environment, and is the basic libaries and support for running existing java applications. It generally comes with support for the plugins that allow applets to be run within a browser. By contrast the JDK (Java Development Kit) also includes tools for compiling and running new java applications (e.g javac the java compiler and the debugger)

Marcus
 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi amit
i liked to put some additional point in ur understanding.
after the initialization of the static contentthe instance variables(i.e member variables) will be get initialized b4 converting to byte code. the rest is ok to my knowledge.

any comments on my point??
 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no.........instance variables or any non-static initializers are only executed whenever we are calling the constructor of the very same class for object creation......they will not come into picture until and unless there is an object is created..........

ppl out there plz give ur valuable cooments on my original question about he Strings.......
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic