步驟-1:創建Java類和寫一個下面的代碼,並保存爲Math.java在記事本中或使用Eclipse IDE。
public class Math
{
public static void addition(){
int a = 20;
int b = 10;
System.out.println(a+b);
}
public static void subtraction(){
int a = 20;
int b = 10;
System.out.println(a-b);
}
public static void division(){
int a = 20;
int b = 10;
System.out.println(a/b);
}
public static void multiplication(){
int a = 20;
int b = 10;
System.out.println(a*b);
}
public static void main(String[] args)
{
System.out.println("Lets Do the Math ");
Math objectMath = new Math();
objectMath.addition();
objectMath.subtraction();
objectMath.division();
objectMath.multiplication();
}
}
步驟2:轉換使用Eclipse保存爲Math.Jar
步驟3該文件以可執行jar文件:創建在記事本中或記事本++一個bat文件,並保存爲數學。蝙蝠
@echo off
"%JAVA_HOME%\bin\java" -cp "Path of XYZ.Java File" XYZ
java -jar Math.jar parameter
echo Successfully Compiled
pause
步驟4:雙擊.bat文件它應該工作。
注意:請確保bat文件的java文件和jar文件都在相同的時候嘗試。
輸出 讓我們做數學題
成功編譯
按任意鍵繼續。 。 。
複製類文件到其他電腦文件夾 cd到該文件夾 不是運行 C:\ Program Files文件\的Java \ jdk1.7.0_09 \ BIN \ java中 –
andy
2013-05-09 13:05:07