Using jar files - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Using jar files

Description:

When you program in Java you find the number of class ... Or use WinRar. www.win-rar.com - $29. G51PRG-Sem2. Where do I put a jar file? In the classpath... – PowerPoint PPT presentation

Number of Views:305
Avg rating:3.0/5.0
Slides: 10
Provided by: davidgrah
Category:
Tags: files | jar | using | winrar

less

Transcript and Presenter's Notes

Title: Using jar files


1
Using jar files
  • Dave Elliman

2
Why jar
  • When you program in Java you find the number of
    class files grows rapidly
  • Computer programmers are tidy people
  • Collect them in jar
  • jar cvf myclasses.jar .class
  • A jar compresses the files too
  • A jar can be signed and verified beyond PRG.

3
Things to look out for
  • You need to be able to find the jar command
    your PATH should have something like
  • PATHC\Program Files\Java\jdk1.5.0_05\bin
  • Note and \ on Windows and / on unix
  • Jar cvf is just like tar cvf on unix

4
When do I make a jar?
  • A good time is when some classes are stable (they
    work!)
  • You can have several jars
  • It can be helpful to look inside a jar this
    lists the files
  • Jar tvf myfiles.jar
  • Or use WinRar
  • www.win-rar.com - 29

5
Where do I put a jar file?
  • In the classpath.
  • CLASSPATHCmyhome\libs\myfiles.jar ..
  • The lazy-mans way is
  • drop it in
  • C\Program Files\Java\jre1.5.0_05\lib\ext

6
Another good reason for using a jar
  • You can package your application in a jar and
    make it run directly from the jar
  • You have to tell the jar file which class has
    main()
  • Create Manifest.txt which contains
  • Main-Class MyPackage.MyClass

7
Then
  • Just include Manifest.txt in the list of files
    going into the jar
  • Then you can run it as
  • java jar myfiles.jar
  • Or in Windows you could set up java jar as the
    default command for .jar files
  • Explorer-Tools-Folder Options
  • Double click on the jar file and it runs

8
Or
  • Build it in Visual J and you get a .exe file
    that runs
  • But that is not real Java

9
How do I extract stuff from a jar
  • jar xvf myfiles.jar
  • Again just like tar xvf
  • There is a u flag for update but I never bother.
    Delete it and create it again.
Write a Comment
User Comments (0)
About PowerShow.com