赞
踩
Create a new Java Project named "demolib".
Add the Class "demolib.DemoLib.Java" containing the following code:
package demolib;
public class DemoLib {
public static void sayHello() {
System.out.println("Hello");
}
}
The Project should look something like this:
In the "Package-Explorer" (not the "Resource-View") right click on the project "demolib".
Select "+ Build Fat Jar".
A Configuration Dialog appears. Just press "Finish".
The File "demolib_fat.jar" has been created in the project root directory.
Create a new Java Project named "demorun".
In the project properties add the Library "demolib/demolib_fat.jar" to the Java Build Path":
Add the Class "demorun.DemoRunMain.java" containing the following code:
package demorun;
import demolib.DemoLib;
public class DemoRunMain {
public static void main(String[] args) {
DemoLib.sayHello();
}
}
The Project should look something like this:
Start the Export Wizard from the File-Menu ("File" -> "Export").
Select "+ Fat Jar Exporter" and click "next >".
Select the project "demorun" and click "next >".
A Configuration-Dialog appears showing the current Settings.
The Main Class - the one containing the static methode main - must be defined in the jar.
Click on the "Browse..." Button on the right side behind the Main-Class Edit field.
Select "DemoRunMain" and click the "OK" Button.
The FullyQualifiedName "demorun.DemoRunMain" is now set for "Main-Class".
Save the current Settings by clicking on the "Finish" Button.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。