Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

08 March, 2010

Create JAR file in Java & 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.

JAR file using Java commands

Following are few commands that can be used to create/view/modify/execute a JAR file using Java command line utilities and JVM.

Create a JAR file

1jar cf JAR_FILE_NAME FILE_NAMES_OR_DIRECTORY_NAME
2e.g.
3jar cf MyApp1.jar C:\JavaProject\MyApp

View contents of a JAR file

1jar tf JAR_FILE_NAME
2e.g.
3jar tf MyApp1.jar

View contents with detail of a JAR file

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

Extract content of JAR file

1jar xf JAR_FILE_NAME
2e.g.
3jar xf MyApp1.jar

Extract specific file from JAR file

1jar xf JAR_FILE_NAME FILE_NAME(S)_FROM_JAR_FILE
2e.g.
3jar xf MyApp1.jar Test1.class

Update a JAR file

1jar uf JAR_FILE_NAME FILE_NAMES_FROM_JAR_FILE
2e.g.
3jar uf MyApp1.jar Test1.class

Executing a JAR file

1java -jar JAR_FILE_NAME
2e.g.
3java -jar MyApp.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.
1Manifest-Version: 1.0
2Main-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.
1jar cvfm MyApp.jar MANIFEST.MF FILE_NAMES_OR_DIRECTORY_NAME

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.

Courtesy: Viral Patel
Author: Viral Patel

05 November, 2007

GlassFish

Overview:
In June 2005, Sun launched the GlassFish project -- an action that opened to the Java community the development of an application server that will be compliant with Java Platform, Enterprise Edition (Java EE) 5. Since then a large and growing community of developers has actively participated in the project.

Community:
The GlassFish community currently includes over 1100 members participating in the GlassFish project, with the objective of developing an open source application server that implements Java EE 5. In addition, the community is working to develop various web services technologies apart from the application server development effort. The community includes independent contributors as well as contributors from various organizations and companies. Members of the GlassFish community don't necessarily have to take an active role in developing code for the application server. By simply using the application server, they can file and track bugs and exchange information with other community members.

Projects:
The GlassFish project is a structured environment for developing the open source application server. The establishment of the GlassFish project is part of a larger effort by Sun to release major portions of its code into open source for use and improvement by the community. The GlassFish project is one of a variety of community-based projects hosted on java.net.

An open source application server:
GlassFish community is building an open source application server within the GlassFish project. The open source application server is based on the source code for Sun Java System Application Server Platform Edition 9, donated by Sun Microsystems, and on source code for TopLink, a Java object-to-relational persistence architecture, donated by Oracle. The GlassFish community makes periodic builds of the open source application server available for download.

About GlassFish Project:
GlassFish puts a free, open source, commercial-grade implementation of Java EE 5 in the hands of the community -- and puts it there early. Think about what benefits this might have for you. If you develop enterprise Java applications, being a GlassFish community member gives you an early opportunity to develop those applications and test them for conformance to Java EE 5. Note that conformance to Java EE 5 cannot be assured until the Java EE 5 specifications are final.
If you maintain enterprise Java applications, you can get an early start in migrating to Java EE 5. You can also get an early look at some of the new features in Java EE 5, such as the new Java Persistence API, the enhanced mapping capabilities in Java Architecture for XML Binding (JAXB) 2.0, the simplified interface for web services development in the Java API for XML Web Services (JAX-WS ) 2.0, as well as the ease-of-development improvements in Enterprise JavaBeans 3.0 technology. You can try out some of the new features in applications that you deploy to the GlassFish application server.
Another significant way in which community members contribute is by exchanging information. Whether it's through postings on the GlassFish discussion forum, broadcasts to mailing lists, or blog entries, members of the community maintain a continuing dialog about many aspects of the project, such as personal insights about GlassFish features, project-development issues, and answers to technical questions. Additionally, The Aquarium, a group blog, collects news related to the GlassFish community from a variety of sources. These communication channels provide a free-flowing information pipeline between members of the GlassFish community, including Sun and Oracle engineers.
GlassFish also gives community members the opportunity to improve the application server code. Developers have told Sun that they want the ability to contribute fixes and new features to Sun's code. The GlassFish project gives community members the context to do just that. As a member, you can identify bugs in the GlassFish code, contribute fixes, and even add new features.



References:
http://java.sun.com/developer/technicalArticles/glassfish/GFBasics.html