用批处理打包J2ME程序

用批处理打包J2ME程序

 

1.源码放于src,资源文件放于res。

2.tempclass存放编译的.class文件。

3.preverify存放预编译后的.class文件。

4.jar存放包。

5.proguard存放混淆包。

 

 

批处理内容:

 

@echo off rem 2010年4月10日 12时52分41秒 rem javac added the restricts: -source 1.3 -target 1.3 rem Do the 'preverify' command. rem create a complete jar with res. if "%OS%"=="Windows_NT" setlocal set JAVAC=E:/Java/jdk1.6.0_14/bin/javac.exe set JAVA=E:/Java/jdk1.6.0_14/bin/java.exe set JAR=E:/Java/jdk1.6.0_14/bin/jar.exe set J2MEBOOT=D:/MissionSetup/SunWTK2_5_2 set CLDCAPI=%J2MEBOOT%/lib/cldcapi11.jar set MIDPAPI=%J2MEBOOT%/lib/midpapi20.jar set EXTRAAPI=%J2MEBOOT%/lib/jsr75.jar set EXTRAAPI=%EXTRAAPI%;%J2MEBOOT%/lib/jsr082.jar set EXTRAAPI=%EXTRAAPI%;%J2MEBOOT%/lib/jsr179.jar set EXTRAAPI=%EXTRAAPI%;%J2MEBOOT%/lib/mmapi.jar set EXTRAAPI=%EXTRAAPI%;%J2MEBOOT%/lib/wma20.jar set PREVERIFY=%J2MEBOOT%/bin/preverify.exe set PROGUARD=D:/MissionSetup/proguard4.4/lib/proguard.jar set DESTINATION=tempclass set PRE_DES=preverify set SOURCE=src set RES=res set JARNAME=demo set JAROUTPUT=jar set PROGUARDOUTPUT=proguard set MANIFEST=MANIFEST.MF set JAVA_FILES= set JAVA_FILES=%JAVA_FILES% %SOURCE%/j2me/shell/*.java if not exist ./%SOURCE% ( echo [debug] Can't find the source folder! echo [debug] Cancel the mission! goto end ) if not exist ./%DESTINATION% ( echo [debug] Create a folder named '%DESTINATION%' md ./%DESTINATION% ) else ( echo [debug] There has been a folder named '%DESTINATION%'. echo [debug] Delete it then create a new empty folder with same name. rd /s /q ./%DESTINATION% md ./%DESTINATION% ) echo [debug] Javac all the '.java' files. %JAVAC% -verbose -g:none -source 1.3 -target 1.3 -bootclasspath %CLDCAPI%;%MIDPAPI%;%EXTRAAPI%;. -classpath %CLDCAPI%;%MIDPAPI%;%EXTRAAPI%;%DESTINATION% -d ./%DESTINATION% %JAVA_FILES% if not exist ./%PRE_DES% ( echo [debug] Create a folder named '%PRE_DES%'. md ./%PRE_DES% ) else ( echo [debug] There has been a folder named '%PRE_DES%'. echo [debug] Delete it then create a new empty folder with same name. rd /s /q ./%PRE_DES% md ./%PRE_DES% ) echo [debug] Preverify the class file. %PREVERIFY% -classpath %CLDCAPI%;%MIDPAPI%;%EXTRAAPI%;%PRE_DES%; -d %PRE_DES% %DESTINATION% if exist %JAROUTPUT% ( echo [debug] There has been a folder named '%JAROUTPUT%' echo [debug] Delete it then create a new empty folder with same name. rd /s /q %JAROUTPUT% md %JAROUTPUT% ) else ( echo [debug] Create a folder named '%JAROUTPUT%' md %JAROUTPUT% ) if exist %JARNAME%.jar ( echo [debug] Delete the %JARNAME%.jar to create a new jar file. del %JARNAME%.jar ) echo [debug] Package a jar file. %JAR% cmf %MANIFEST% %JARNAME%.jar -C %PRE_DES% . if exist %RES% ( echo [debug] Add the resource to the jar file. %JAR% uf %JARNAME%.jar -C %RES% . ) copy %JARNAME%.jar ./%JAROUTPUT% del %JARNAME%.jar if exist %PROGUARD% ( echo [debug] Create a obfuscated jar file. if not exist %PROGUARDOUTPUT%/proguard.pro ( echo [debug] Can't found the %PROGUARDOUTPUT%/proguard.pro file.Cancel obfuscated action. goto end ) ) cd %PROGUARDOUTPUT% %JAVA% -jar %PROGUARD% @proguard.pro cd .. :end if "%OS%"=="Windows_NT" endlocal pause @echo on

 

 

proguard.pro 文件内容为:

 

-injars D:/Test/CommandLine/javac/jar/demo.jar -outjars D:/Test/CommandLine/javac/proguard/demo_pro.jar -libraryjars D:/MissionSetup/SunWTK2_5_2/lib/midpapi20.jar -libraryjars D:/MissionSetup/SunWTK2_5_2/lib/cldcapi11.jar -libraryjars D:/MissionSetup/SunWTK2_5_2/lib/mmapi.jar -libraryjars D:/MissionSetup/SunWTK2_5_2/lib/wma20.jar -libraryjars D:/MissionSetup/SunWTK2_5_2/lib/jsr75.jar -overloadaggressively -repackageclasses '' -allowaccessmodification -microedition -keep public class CommandLineMIDlet

你可能感兴趣的:(j2me,jar,delete,java,windows,class)