Original: Idea development Swing (ii)
Gossip less, book pick Idea Development Swing (a).
After the program is compiled, you need to package the release, if you have Fat_jar students can be packaged through the plug-in, here is the use of ant to package, the steps are as follows:
First, the preparation of Build.xml
<?XML version= "1.0" encoding= "UTF-8" standalone= "no"?><Projectdefault= "Create_jar"name= "Swingdemo"> < Propertyname= "Src.dir"value= "src"/> < Propertyname= "Build.dir"value= "Target"/> < Propertyname= "Classes.dir"value= "Classes"/> < Propertyname= "Jar.dir"value= "${build.dir}/jar"/> < Propertyname= "Lib.dir"value= "Lib"/> < Propertyname= "Config.dir"value= "config"/> < Propertyname= "Plugin.dir"value= "Plugin"/> < Propertyname= "Db.dir"value= "db"/> < Propertyname= "Jar_name"value= "App"/> < Propertyname= "Start_class"value= "Swingdemo." Swingdemomain "/> <PathID= "Application" Location= "${jar.dir}/${jar_name}.jar"/> <PathID= "Lib_path"> <Filesetdir= "${lib.dir}"includes= "**/*.jar"/> </Path> <Targetname= "clean"Description= "Clear Build"> <Deletedir= "${build.dir}"/> </Target> <!--The compilation system has INTELLIJ processing <target name= "compile" description= "compile System" > <mkdir dir= "${classes.dir}"/> <javac srcdir= "src" destdir= "${classes.dir}" encoding= "GBK" classpathref= "Lib_path"/> </target> - <Targetname= "Resource"Description= "Initialize resource file"> <mkdirdir= "${build.dir}"/> <mkdirdir= "${build.dir}\jar"/> <copydirdest= "${build.dir}\lib"src= "${lib.dir}"/> <copydirdest= "${build.dir}\config"src= "${config.dir}"/> <copydirdest= "${build.dir}\db"src= "${db.dir}"/> <copydirdest= "${plugin.dir}\plugin"src= "${plugin.dir}"/> <CopyTodir= "${build.dir}"file= "Start.bat"/> </Target> <Targetname= "Create_jar"depends= "Clean,resource"Description= "packaged"> <Pathconvert Property= "Mf.classpath"Pathsep=" "> <Mapper> <Chainedmapper> <!--Remove Absolute path - <Flattenmapper/> <!--plus lib prefix - <Globmapper from="*" to=".. /lib/* " /> </Chainedmapper> </Mapper> <Filesetdir= "${lib.dir}"> <includename= "*.jar" /> </Fileset> </Pathconvert> <JarDestFile= "${jar.dir}/${jar_name}.jar"Basedir= "${classes.dir}"> <Manifest> <attributename= "Main-class"value= "${start_class}"/> <attributename= "Class-path"value= "${mf.classpath}"/> </Manifest> </Jar> </Target> <Targetname= "Run"depends= "Create_jar"Description= "Run"> <JavaFork= "true"ClassName= "${start_class}"> <Classpath> <PathrefID= "Lib_path"/> <PathrefID= "Application"/> </Classpath> </Java> </Target></Project>
Ii. Preparation of Start.bat
Set Path=c:\program Files (x86) \java\jdk1.7.0\bin;%path%-jar Swingdemo.jar
Third, join the LIB package
Due to the layout of the IntelliJ that the program uses, it is necessary to refer to a jar package within IntelliJ, where the jar package is located in:. /intellij idea 12.1.1/lib/forms_rt.jar, copy the jar package to the project's Lib folder.
Iv. calling the ant script
Click the Ant Build button on the plug-in panel on the right side of the IntelliJ idea workspace, click "+" to add the Build.xml file in the project, and you can choose four stages to package the program.
V. Completion of
After the package is complete, the target folder is generated under the project path, the folder contains the program and the required files, click Start.bat to run.
IntelliJ Idea Development Swing (ii)