Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Development Jar Files for Applications and Libraries

Similar presentations


Presentation on theme: "Software Development Jar Files for Applications and Libraries"— Presentation transcript:

1 Software Development Jar Files for Applications and Libraries
Computer Science 209 Software Development Jar Files for Applications and Libraries

2 Byte Codes Everywhere! The Java compiler creates a set of byte code files (with a .class extension) The main method’s byte code file can then be run with the java command Library code, including package directories, must be placed in the current working directory

3 Jar files to the Rescue! An entire application can be bundled in a single file with a .jar extension This file can be launched by double-clicking or be run with the java command A package can be bundled in a single file with a .jar extension, and placed in Java’s system directory for the use of any Java application

4 Creating an Executable Jar File
Open a text editor and create a text file named manifest.tmp. Include one line of code that specifies the main class name for the application. For example, if your main class is named TestStudent, enter the following code in this file: Main-Class: TestStudent

5 Creating an Executable Jar File
For simple programs, place just the byte code files in the same directory that includes manifest.tmp, and run the following command: > jar –cfm TestStudent.jar manifest.tmp *.class

6 Running an Executable Jar File
Now, you can either launch the jar file by double-clicking on it or run it at the command line as follows: > java –jar TestStudent.jar

7 Creating a Jar File for a Library
Place the package directory for the library in your current working directory. If there is more than one package involved, they must be organized in a hierary of subdirectories. Each directory should contain byte code files. You may include image files in appropriate subdirectories as well.

8 Creating a Jar File for a Library
At the command prompt, run the jar command with the tag cvf, the name of the jar file, and the top-level package directory name. For example, if the package name is BreezySwing, you would run the command > jar cvf BreezySwing.jar BreezySwing

9 Using a Jar File for a Library
Place the jar file in the appropriate system directory for Java on your computer. For example, on a Mac, this directory is <Your Hard Drive>/Library/Java/Extensions On a PC, these directories are C:\Program Files\Java\jre1.8.0_144\lib\ext C:\Program Files\Java\jdk.8.0_144\lib C:\Program Files\Java\jdk.8.0_144\jre\lib\ext

10


Download ppt "Software Development Jar Files for Applications and Libraries"

Similar presentations


Ads by Google