How java takes out the Garbage?

  1. Each time an object is created in java, it goes into an area of memory known as The Heap. ( Heap –  heap is an area of pre-reserved computer main storage ( memory ) that a program process can use to store data in some variable amount that won’t be known until the program is running.)
  2. All Objects – no matter when , where, or how they’re created – live on the the Heap.
  3. But its not just any old memory heap; the Java heap is actually called the Garbage-Collectible heap.
  4. When you create an Object, Java Allocates memory space on the heap according how much that particular object needs.
  5. An Object with say , 15 instance variables, will probably need more space than an Object with only two instance variables.
  6. But what happens when you need to reclaim the space ? How do you get an object out of the heap when you’re done with it ? Java manages that memory for you! when the JVM can ‘see’ that an Object can never be used again, that object become eligible for garbage Collection.
  7. And if you’re running low on memory, the Garbage Collector will run, throw out the unreachable objects, and free up the space, so that the space can be reused.

Setup JDK, JRE, Apache Ant at Environment Variable – run on CMD Prompt

1. Download Java SE
– download : http://www.oracle.com/technetwork/java/javase/downloads/index.html

1.1. Purpose Java SE:
– “JDK” is the Java Development Kit. I.e., the JDK is bundle of software that you can use to develop Java based software.

2. Download JRE
download :http://www.oracle.com/technetwork/java/javase/downloads/index.html

2.1. Purpose of JRE:
– JRE is an implementation of the Java Virtual Machine which actually executes Java programs.

3. Apache Ant
download :http://ant.apache.org/bindownload.cgi

3.1. Purpose of Apache Ant:
– Apache Ant is a Java library and command-line tool that help building software.

4. After Download And Install – Lets Set The Environment Variable :

4.1. Click Start > Computer – Right Click > Properties > Advanced System Setting >  Click Environment Variable
4.1.1. JDK –variable Name : JAVA_HOME
– Variable value: C:\Program Files\Java\jdk1.7.0_25\bin

4.1.2. JRE –Java runtime Variable : JRE_HOME
– Variable Value: C:\workspaces\java\jre1.6.0_07\bin

4.1.3. Apache Ant  Variable : ANT_HOME
– Variable Value : C:\Program Files\Java\apache-ant-1.9.2\bin

5. Create a directory on your computer where java source are store
C:\java_source

5.1. Check java Version
java -version

5.2. Check the JDK Version
javac -version

5.3. Compile the java source.
Command : Javac HelloWorld.java

5.4. Run the Class Java.
Command : Java HelloWorld
Output : Hello, World!

6. Setup JDK, JRE in the Environment variable in Windows 8.

Nothing new, just search environment variable and setting like setting in Windows XP or Windows 7