怎么打jar包 jar怎么运行
一、怎么打jar包
第一步:选中要打jar包的工程
第二步:鼠标右击,选择Export...
第三步:选择java中的Runnable JAR file(如图)

点击“Next”
第四步:(1)在Launch configuration:选择要打jar包的mian所在的类名;(如图)

(2)在Export destination:选择要存放jar的名称和地址(如图)

(3)如果要打的jar包需要调用别的jar包 请选择Library handling:中copy required libraries into a sub-folder next to the generated JAR(如图)

第五步:点击 “Finish”
二、运行 jar 方法
(1)cmd
(2)java -jar 盘:\文件名\XXXX.jar
请问,如果我里面写成循环执行,执行jar包,那要怎么结束
感谢LZ,终于搞定了eclipse导出jar,并且在dos里面可以运行了
:wink:
/** * 遍历目录 * * @param directoryPath / public static void read(String txtPath, String xmlPath) { File dir = new File(txtPath); File files = dir.listFiles(); if (files == null) { return; } else { for (int i = 0; i < files.length; i++) { if (files.isDirectory()) { read(files*.getAbsolutePath(), xmlPath); } else { // read file readfile2Xml(files*.getAbsolutePath(), xmlPath); } } } }
}
/** * 读取文件 每行生成一个Element * * @param file */ private static void readfile2Xml(String file, String xmlPath) { String fileName = file.substring(file.lastIndexOf("\") + 1, file .lastIndexOf(".")); String func = null; String funcName = null; String funcSize = null; InputStreamReader read = null; BufferedReader reader = null; counts = 0; sizes = 0; try { // 添加summary addSummary(fileName, xmlPath); // 添加detail addElement(fileName, null, null, xmlPath);
/** * 添加Summary * * @param moduleName * @param countTotal * @throws IOException * @throws JDOMException */ private static void addSummary(String moduleName, String xmlPath) throws JDOMException, IOException {
/** * 文件处理 * * @param doc * @throws IOException * @throws FileNotFoundException */ private static void output(Document doc, String xmlPath) throws FileNotFoundException, IOException { // 格式化并输出 Format format = Format.getPrettyFormat(); XMLOutputter out = new XMLOutputter(format); out.output(doc, new FileOutputStream(xmlPath)); }
public class TxtFmtXml { // 模块包含的函数个数 private static Integer counts = 0; // 模块所包含函数的大小 private static Integer sizes = 0;
package com.huawei.txtfmtxml;
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.List;
import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; import org.jdom.input.SAXBuilder; import org.jdom.output.Format; import org.jdom.output.XMLOutputter; import org.jdom.xpath.XPath; /** * *请提供jaxen.jar(XPath要用到)、jdom.jar **/
:wink:
把jar包复制到另一路径下再运行,看行不行?