Jar's
You will not be tested on the content on this page and this content will not be covered on the AP Computer Science exam.
Objective #1: Create an executable jar file that can also be used as a library class.
- A jar file is a compressed file (like a zip file on a Windows computer) that contains .class and other files including a manifest file that tells the computer which class contains the main method.
- A jar file can be used as an executable file so that it executes on a Windows PC when you double-click it. In theory, the file will also execute on a Mac or Linux computer however the button and window styles may have a different look and feel.
- All of the files used by a project are combined into the executable jar file.
- Follow the instructions at www.skylit.com/javamethods/faqs/createjar.html
- To build a jar file from the command line, use
%JAVA_HOME%\jar cmf MainClassClient nmtClient.jar nmt
and in the same folder as the class files you are placing in the jar is a
plain text file called MainClassClient (with no file extension.)
This file contains one line of text:
"Main-Class: nmt.NMTClient"
- The program JSmooth from jsmooth.sourceforge.net can be used to convert a jar file into an exe file.