Creating Jar Files Jin Hung, Gregory Olds, George Blank, Sun Java Web Site.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 4 Writing Java Applications, Java Development Tools.
Advertisements

Packages Sudhir Talasila Preeti Navale. Introduction Packages are nothing more than the way we organize files into different directories according to.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 3.
Applet Security Gunjan Vohra. What is Applet Security? One of the most important features of Java is its security model. It allows untrusted code, such.
1 Configuring Internet- related services (April 22, 2015) © Abdou Illia, Spring 2015.
Objectives:1. Archiving and Packaging Java Code 2. The jar Program 3. Example Applet JAR Files.
JAR and Packages Section 4.5 (JIA’s) Section 3.3 (ALBING’s) Section 5.11 (ALBING’s)
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 18 Applets and Multimedia.
1 Applets. 2 Motivations When browsing the Web, you frequently see the graphical user interface and animation developed using Java. These programs are.
Objectives:1. Archiving and Packaging Java Code 2. The jar Program JAR Files.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L06 (Chapter 16) Applets.
Installing JDK Vijayan Sugumaran Department of DIS Oakland University.
CASE STUDY: Applet Development with GUI and Client-side File Input Arkadiusz Edward Komenda.
Java Jar Files Bar-Ilan University תשס"ה by Moshe Fresko.
Tutorial 7 Working with Multimedia. XP Objectives Explore various multimedia applications on the Web Learn about sound file formats and properties Embed.
Deploying Java applications as JAR files SE-2030 Dr. Mark L. Hornick 1 How to package an application so that you can run it outside of Eclipse.
עיצוב תוכנה מונחה עצמים תירגול 1. 1.Packages and Paths 2.Jar Files Outline.
Chapter 55 How to Construct JAR files for Program Distribution.
SERVLETS.
Packaging Java software. What the problem is zAn executable program often consists of a very large number of files zIt's a nuisance to manage lots of.
Javascript and the Web Whys and Hows of Javascript.
How to Download and Install a Sharp Print Driver on a Mac.
Java How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Tutorial 7 Working with Multimedia. XP Introducing Multimedia Bandwidth is a measure of the amount of data that can be sent through a communication pipeline.
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
Slides © Marty Hall, book © Sun Microsystems Press 1 Including Files & Applets in JSP Documents Core Servlets & JSP book:
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES LECTURE 5_1 George Koutsogiannakis/ Summer
Applets Chapter 17.  Java’s big splash onto the scene came in the mid 90’s. The people at Sun Microsystems had managed to work java programs into Web.
Tutorial 7 Working with Multimedia. XP Objectives Explore various multimedia applications on the Web Learn about sound file formats and properties Embed.
Deploying Java applications as JAR files SE-2030 Dr. Rob Hasker 1 Based on material by Dr. Mark L. Hornick.
1 Introduction to Applets. 2 Applications Programs that execute using the java interpreter Executes in command windows.
Database-Driven Web Sites, Second Edition1 Chapter 5 WEB SERVERS.
The Basics of Javadoc Presented By: Wes Toland. Outline  Overview  Background  Environment  Features Javadoc Comment Format Javadoc Program HTML API.
Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html.
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
Tutorial 7 Working with Multimedia
Tutorial 7 Designing a Multimedia Web Site
POS 406 Java Technology And Beginning Java Code
Tutorial 7 Working with Multimedia. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Explore various multimedia applications.
Tutorial 7 Working with Multimedia. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Explore various multimedia applications.
Deployment via jars and Webstart. How do we distribute our application? Lab says you need to submit CD Lab says you need to submit CD Limitations of CD.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved GUI: Applets and Multimedia.
Ant & Jar Ant – Java-based build tool Jar – pkzip archive, that contains metadata (a manifest file) that the JRE understands.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 16 Applets and Multimedia.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
Csci5931 Web Security1 Java Security Model (GS: Ch. 7)
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Using This PowerPoint This PowerPoint presentation assumes your Computer Science teacher has provided you with the InstallingJava folder, which contains.
Applets, Images, and Audio Chapter 14 CSCI CSCI 1302 – Applets, Images, and Audio2 Outline Introduction The Applet Class –The init Method –The start.
Jar Files The Basics. 2 Outline Create a Jar Viewing the Contents of a JAR File Extracting the Contents of a JAR File Modifying a Manifest File Running.
Intro to. Contents These slides describe how one can obtain (download) and use eclipse to build, run, and debug basic Java programs.
Software Design– Unit Testing SIMPLE PRIMER ON Junit Junit is a free simple library that is added to Eclipse to all automated unit tests. The first step,
Introduction of Wget. Wget Wget is a package for retrieving files using HTTP and FTP, the most widely-used Internet protocols. Wget is non-interactive,
Upgrade on Windows 7. DownloadSoftware Download Software from link provided in Webliography: e/
Chapter 23 Applets and Java Web Start
BIF713 Managing Disk Space.
Introduction to Java Applets
Topic: Java Security Models
Software Development Jar Files for Applications and Libraries
Tutorial 7 Working with Multimedia
JAR Files Objectives: 1. Archiving and Packaging Java Code
Understanding and Creating Jar files in Java
Configuring Internet-related services
Introduction to Computing Using Java
Executable Jars Dan Fleck Fall /27/2018.
How Java Program Executes
Review of Previous Lesson
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
Presentation transcript:

Creating Jar Files Jin Hung, Gregory Olds, George Blank, Sun Java Web Site

What is a Jar File? Java archive (jar) files are compressed files that can store one or many files. Jar files normally contain java or class files, but other files may also be included. Jar files can be run on Windows by double clicking jar files if the JVM is installed.

Why use a JAR File? Compression:Jar files reduce the size of the original files. Speed: The applet can be downloaded in one http transaction. Security: Jar files can be signed digitally. Users who recognize the signature can optionally grant permission to run the file or refuse. Package sealing: Sealing a package within the jar file means that all classes defined in that package are found in the same jar file.

Flow Chart Create a manifest.mf file Create a jar file Basic jar commands JAR subdirectories Execute the jar file Common mistakes Bibliography

How to create a jar file: Simple Method The jar command a utility that comes with the JDK. The format of the basic format of the jar command is: Jar cf jar-file input-files

How to create a jar file Take as an example the Java application made from the files –Foo.class –Foobar.class To make a jar file use the command Jar cvf Foo.jar Foo.class Foobar.class Note that each file is separated by a space

How to create a jar file The execution of this command creates the file: –Foo.jar

Executing Jar Application Jar applications can be run with the following basic command: –java -jar jar-file So to run our Foo.jar if it was an application use: –java -jar Foo.jar

Executing Jar Application Many Operating systems such as the Mac OS will allow the execution of jar applications by simply double clicking on them.

Executing Jar Applets Applets are invoked from applet tags in HTML code. To execute an Applet simply add the name of the jar file into the applet tag is under the archive parameter.

Executing Jar Applets For example, using the applet tag for your Foo.jar archive, you would use the following: <applet code=TicTacToe.class archive=”Foo.jar" width=120 height=120>

Creating Jar Files: Advanced method The more formal and complete way to create a jar file is described in the following slides. Note that the more complex your process, the more difficulty a beginning Java user is going to have with it.

Create manifest.mf Create a new notepad file named manifest.mf. This file contains a signal line that points out the main class. Here is the signal line. Main-Class: name of main class  Blank line must be included because some Windows OS versions need it. For example: myClass is my main Class. So manifest.mf is following. Main-Class: myClass

Jar file and Jar Commands Next, create a jar file using the “jar” command in java. Here is the command. jar cvmf.jar manifest.mf A.class B.class …….. There are spaces between each file and class name.  Here are the basic jar commands Create Jar file => jar cf jar-file input-file View Jar file => jar tf jar-file Extract Jar file => jar xf jar-file

JAR Subdirectories The JAR format also support storing files in a directory structure. Consider the following structure. Note: CS 602 students have had a lot of difficulty getting files to work in sub- directories. If you have trouble, put all your files in your default Web directory.

JAR Subdirectories

If we want to keep the same structure, we can compress files by typing: jar cmf Sample.mf Sample.jar Sample.class Turtle.class Sample.java Turtle.java images

JAR Subdirectories The contents listing appears as: META-INF/ META-INF/MANIFEST.MF Sample.class Turtle.class Sample.java Turtle.java images/ images/image1.gif images/image2.gif images/image3.gif

Executing the Jar File There are two ways to execute jar files. 1. If an OS can read *.jar as javaw.exe or java.exe, users can double click jar files on the window. Otherwise: 2. In a command window, type in java –jar jar-file

Common Mistakes Forgetting to leave a blank line after the main class declaration in the manifest.mf. OS may return “Fail to load Main-Class manifest attribute” error in Windows machines. Failing to compress all your files. You have to type in all the files you want to compress. Separate these files with a space.

Bibliography Xiaoping Jia, Object-Oriented Software Development Using Java, Addison Wesley, 2nd Edition, Packaging Programs in JAR Files, and Running JAR-Packaged Software ment/jar/index.html ment/jar/index.html