Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming I Packets and JAR 11th lecture.

Similar presentations


Presentation on theme: "Programming I Packets and JAR 11th lecture."— Presentation transcript:

1 Programming I Packets and JAR 11th lecture

2 © Branko Kavšek, Jernej Vičič
Packets What are packets and how do we use them? The JAR tool 11th lecture Programming I © Branko Kavšek, Jernej Vičič

3 © Branko Kavšek, Jernej Vičič
Overview Basic libraries Packets JAR Swing JavaDoc 11th lecture Programming I © Branko Kavšek, Jernej Vičič

4 Basic libraries JavaTM SE 6 Platform
Java Platform, Standard Edition 6 JDK. Version 6

5

6 Paketi paketi (packages) so knjižnice Java objektov.
v program jih lahko uvozimo z besedo import. Java API vsebuje veliko različnih paketov, lahko pa pakete naredimo tudi sami. Paket je tesno povezan z imenikom datotečnega sistema Vsi javni razredi, ki so v nekem imeniku se lahko med sabo kličejo.

7 Packets All public classes that are in a directory can call each other. Package behaves as a directory, all the classes of a package are friends (you can call another method, modify / read properties). We must store all classes in the same directory at design time. Packages can be placed in a Java JAR archive.

8 Packts - example import java.lang.Math; // sedaj lahko uporabljamo metodi iz Math public class Bla { public static void main(String argv[]) { double x=5; System.out.println(Math.sin(x)); // kličemo Math.sin(3.14); }

9 Packets package PrviPaket; public class Razred{
public static void main(String args[]){ System.out.println("Dober dan!"); } } // Razred

10 Packets Content of the example must be saved in the file Razred.java, which is located in the directory PrviPaket. Compile file Razred.java as an ordinary Java program. The implementation is slightly different: java PrviPaket/Razred

11 Pakets - JAR Jar is Java Archive.
It is a file format based on the zip and is used to combine multiple files into one. It is primarily designed to facilitate and speed up the handling of java projects. It handles (in addition to Class files) also images similar rubbish.

12 Packets - JAR Make a jar archive: jar cvf pp.jar PrviPaket/
Start a class in an archive (add to classpath): java -classpath pp.jar PrviPaket/Razred Executable jar files: Open a nerw jar file. Find file MANIFEST.MF Add the line: Main-Class: PrviPaket/Razred Make a new archive: jar cvfm pp1.jar c:\temp\MANIFEST.MF PrviPaket/ Start: java -jar pp1.jar

13 © Branko Kavšek, Jernej Vičič
Swing – why, how, who? Sun and allies JFC AWT Java 2D Accessibility Drag and Drop Swing 11th lecture Programming I © Branko Kavšek, Jernej Vičič

14 © Branko Kavšek, Jernej Vičič
Swing usage Analogous to AWT components Add the letter J Additional componnets 11th lecture Programming I © Branko Kavšek, Jernej Vičič

15 © Branko Kavšek, Jernej Vičič
Swing - usage tree = new JTree(); list = new JList(items); button = new JButton("Pritisni"); button.addActionListener(new ButtonListener()); 11th lecture Programming I © Branko Kavšek, Jernej Vičič

16 Swing – Differences between Swing and AWT
All components are written in Java AWT components are only envelope Uniform look on all platforms Look up Greater control over the components Pluggable Look and Feel Slow and greedy 11th lecture Programming I © Branko Kavšek, Jernej Vičič

17 © Branko Kavšek, Jernej Vičič
Swing Windows look 11th lecture Programming I © Branko Kavšek, Jernej Vičič

18 Swing metal (Java) look
11th lecture Programming I © Branko Kavšek, Jernej Vičič

19 © Branko Kavšek, Jernej Vičič
Swing Motif look 11th lecture Programming I © Branko Kavšek, Jernej Vičič

20 © Branko Kavšek, Jernej Vičič
Swing Source code: SwingApplet.html 11th lecture Programming I © Branko Kavšek, Jernej Vičič

21 © Branko Kavšek, Jernej Vičič
JavaDoc Example! 11th lecture Programming I © Branko Kavšek, Jernej Vičič


Download ppt "Programming I Packets and JAR 11th lecture."

Similar presentations


Ads by Google