What is a Java Virtual Machine (JVM)?

To understand the Java virtual machine you must first be aware that you may be talking about any of three different things when you say "Java virtual machine." You may be speaking of:
  • the abstract specification,
  • a concrete implementation, or
  • a runtime instance.
The abstract specification is a concept, described in detail in the book: The Java Virtual Machine Specification, by Tim Lindholm and Frank Yellin. Concrete implementations, which exist on many platforms and come from many vendors, are either all software or a combination of hardware and software. A runtime instance hosts a single running Java application. Each Java application runs inside a runtime instance of some concrete implementation of the abstract specification of the Java virtual machine. In this book, the term "Java virtual machine" is used in all three of these senses. Where the intended sense is not clear from the context, one of the terms "specification," "implementation," or "instance" is added to the term "Java virtual machine".

Creating a JAR File using Eclipse IDE

JAR file using Eclipse IDE

Creating JAR file using Eclipse IDE is pretty much easy. Follow the simple steps.
Right click on your project, which you want to create a JAR file of. And select Export from the context menu.

Select JAR file from Java folder and click Next.

Provide the Destination path and click on Finish to create the JAR.

How to Create JAR file in Java and also using Eclipse

Let us see how to create a JAR file using Java’s jar command as well as using Eclipse IDE. The JAR file format is based on the popular ZIP file format. Usually these file are used for archiving and distribution the files and implementing various libraries, components and plug-ins in java applications. Compiler and JVMs (Java Virtual Machine) can understand and implement these formats for java application.


Create a JAR file


jar cf JAR_FILE_NAME FILE_NAMES_OR_DIRECTORY_NAME
 
Eg:
jar cf MyApp1.jar C:\MyProject\MyApp

View contents of a JAR file




jar tf JAR_FILE_NAME
 
e.g.
jar tf MyProject.jar

View contents with detail of a JAR file


jar tvf JAR_FILE_NAME
e.g.
jar tvf MyProject.jar
 
Note that we have used v (verbose) option to see the detail of JAR.

Extract content of JAR file



jar xf JAR_FILE_NAME
e.g.
jar xf MyProject.jar

Extract specific file from JAR file



jar xf JAR_FILE_NAME FILE_NAME(S)_FROM_JAR_FILE
e.g.
jar xf MyProject.jar Test1.class

Update a JAR file


jar uf JAR_FILE_NAME FILE_NAMES_FROM_JAR_FILE
e.g.
jar uf MyProject.jar Test1.class

Executing a JAR file


java -jar JAR_FILE_NAMEe.g.
java -jar MyProject.jar

Create an executable JAR file

In order to create an executable JAR, one of the classes that we include in our JAR must be a main class.
Create a text file called MANIFEST.MF using any text editor and copy following content in it.



Manifest-Version: 1.0
Main-Class: MyMainClass
Where MyMainClass is the name of the class that contents main method. Also note that you have to specify fully qualified class name here.
Use following command to create an executable JAR file.

jar cvfm MyProject.jar MANIFEST.MF FILE_NAMES_OR_DIRECTORY_NAME

How to Increase JVM / Java Heap Size,Increasing JVM / Java Heap Size Tutorial

Java programs executes in JVM uses Heap of memory to manage the data. If your Java program requires a large amount of memory, it is possible that the virtual machine will begin to throw OutOfMemoryError instances when attempting to instantiate an object. The default heap size if 1 MB and can increase as much as 16 MB.

It is possible to increase heap size allocated by the Java Virtual Machine (JVM) by using command line options.
Following are few options available to change Heap Size.

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size
 
Also we can set the Minimum and Maximum Heap size
 
java -Xms64m -Xmx256m MyProgram

jvm out of memory error,Java Out of Memory

I have a question I'm hoping to get some help with.  I have an Oracle 8.1.7 database running on a unix server. The server is also running a java virtual machine. I don't know much about the jvm, but i do know one is running. i have to have it running to run a pl/sql process that uses the oracle xdk package. when i try to run my process with too many reports to parse, i get the error:

ORA-29554: unhandled Java out of memory condition

i assume this means that the jvm ran out of available ram. my question is, does anyone know the details of how to up the memory avaialable to the jvm on the server? if anybody has another opinion on what exactly is causing this error and how to fix it that would be great too. thanks.


Solution:
take a look at that and try setting the two parameters in the init.ora file:

Oracle introduced the following two new init.ora parameters to limit Java  session memory usage:

JAVA_SOFT_SESSIONSPACE_LIMIT  - This parameter allows you to specify a soft limit on the amount of Java         memory usage in a session. If this parameter is exceeded, a message is written to the alert.log. The default is 1 MB.  
JAVA_MAX_SESSIONSPACE_SIZE   - This parameter sets a hard limit on the amount of Java memory usage a  session can have. If a session exceeds this parameter, it terminates  with the following error: ORA-29554 : unhandled Java out of memory condition
The default is 4 GB.  This limit was purposely set very high so that it would not normally be visible.