Jar changes in jdk6

Consider 3 java files in the package pack1.


public class Main {

public static void main(String[] args) {
System.out.println("Main in Main.java");
}
}
public class Main2 {
public static void main(String[] args) {
System.out.println("Main in Main2.java");
}
}
public class Main3 {
public static void main(String[] args) {
System.out.println("Main in Main3.java");
}
}

Compiling all of them gives us the 3 files in the folder pack1.
Main.class Main2.class Main3.class

Now,
bash$jar cvfe main.jar pack1.Main2 pack1
added manifest
adding: pack1/(in = 0) (out= 0)(stored 0%)
adding: pack1/Main.class(in = 533) (out= 329)(deflated 38%)
adding: pack1/Main2.class(in = 537) (out= 331)(deflated 38%)
adding: pack1/Main3.class(in = 537) (out= 332)(deflated 38%)

bash$java -jar main.jar
Main in Main2.java

1 more run for the files without any recompilation or source change
bash$jar cvfe main.jar pack1.Main3 pack1
added manifest
adding: pack1/(in = 0) (out= 0)(stored 0%)
adding: pack1/Main.class(in = 533) (out= 329)(deflated 38%)
adding: pack1/Main2.class(in = 537) (out= 331)(deflated 38%)
adding: pack1/Main3.class(in = 537) (out= 332)(deflated 38%)

bash$java -jar main.jar
Main in Main3.java

Specifying the -e argument to the jar command we can specify which entry point we want in the jar file when running as the standalone application.
This has been added on in JDK 6 onwards.

Also, the timestamps of extracted files are those listed in the archive, instead of the time of extraction.
Eg for the same.
The current time is: 15:54:00.89
And the files information is
06/11/2008 03:46p 533 Main.class
06/11/2008 03:46p 537 Main2.class
06/11/2008 03:46p 537 Main3.class
The file information is the one when I created the class files.

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

I am Vikram Aroskar working in the Java team based out of India.

Search

Categories
Archives
« March 2015
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    
       
Today