自已做的一个小项目(用Socket传文件)在完整的JRE下完成,但在发布的时候,我自已用网上的一个程序精简了JRE(只有3.5M),测试通不过,我发现都是因为项目中引入了外部的jdom.jar包.....另外,在用eclipse导出jar包的时候、还有在用exe4j生成,exe文件的时候,都因为jdom.jar出现过麻烦!!!项目中有一个方法用到jdom.jar---目的在于从一个.xml文件中提取一个String。现在想重写这个方法getDevice(),不再使用jdim.jar,
不知各位老师有好的方法没???非常感谢!!!
附上原来的方法和device.xml: public static String getDevice(){
String value=null;
try{
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new File("d:\\java\\atm\\device.xml"));
Element user= doc.getRootElement();
List devices= user.getChildren("device");
for (int i = 0; i < devices.size(); i++) {
Element device= (Element) devices.get(i);
List devicenos= device.getChildren("deviceno");
for (int j = 0; j < devicenos.size(); j++) {
Element deviceno= (Element) devicenos.get(j);
value= deviceno.getAttribute("value").getValue();
}
}
System.out.println(value);
}catch(Exception e){
e.printStackTrace();}
return value;
}device.xml:(为了得到deviceno 中的value值)
<?xml version="1.0" encoding="GB2312" ?>
- <a re="此雄姿英发" father="NULL">
- <server>
- <local4p>
<local4pport value="9972" />
</local4p>
</server>
- <device>
<devicename value="router" />
<deviceno value="130640164008" />
</device>
- <fkeyposition>
<f1 x="0%" y="39%" value="f1" />
<f2 x="-0%" y="39%" value="f2" />
<f3 x="0%" y="57%" value="f3" />
<f4 x="-0%" y="57%" value="f4" />
<f5 x="0%" y="75%" value="f5" />
<f6 x="-0%" y="75%" value="f6" />
<f7 x="0%" y="92%" value="f7" />
<f8 x="-0%" y="92%" value="f8" />
<f25 x="0%" y="39%" value="f25" />
<f26 x="-0%" y="39%" value="f26" />
<f27 x="0%" y="57%" value="f27" />
<f28 x="-0%" y="57%" value="f28" />
<f29 x="0%" y="75%" value="f29" />
<f30 x="-0%" y="75%" value="f30" />
<f31 x="0%" y="92%" value="f31" />
<f32 x="-0%" y="92%" value="f32" />
</fkeyposition>
</a>
不知各位老师有好的方法没???非常感谢!!!
附上原来的方法和device.xml: public static String getDevice(){
String value=null;
try{
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new File("d:\\java\\atm\\device.xml"));
Element user= doc.getRootElement();
List devices= user.getChildren("device");
for (int i = 0; i < devices.size(); i++) {
Element device= (Element) devices.get(i);
List devicenos= device.getChildren("deviceno");
for (int j = 0; j < devicenos.size(); j++) {
Element deviceno= (Element) devicenos.get(j);
value= deviceno.getAttribute("value").getValue();
}
}
System.out.println(value);
}catch(Exception e){
e.printStackTrace();}
return value;
}device.xml:(为了得到deviceno 中的value值)
<?xml version="1.0" encoding="GB2312" ?>
- <a re="此雄姿英发" father="NULL">
- <server>
- <local4p>
<local4pport value="9972" />
</local4p>
</server>
- <device>
<devicename value="router" />
<deviceno value="130640164008" />
</device>
- <fkeyposition>
<f1 x="0%" y="39%" value="f1" />
<f2 x="-0%" y="39%" value="f2" />
<f3 x="0%" y="57%" value="f3" />
<f4 x="-0%" y="57%" value="f4" />
<f5 x="0%" y="75%" value="f5" />
<f6 x="-0%" y="75%" value="f6" />
<f7 x="0%" y="92%" value="f7" />
<f8 x="-0%" y="92%" value="f8" />
<f25 x="0%" y="39%" value="f25" />
<f26 x="-0%" y="39%" value="f26" />
<f27 x="0%" y="57%" value="f27" />
<f28 x="-0%" y="57%" value="f28" />
<f29 x="0%" y="75%" value="f29" />
<f30 x="-0%" y="75%" value="f30" />
<f31 x="0%" y="92%" value="f31" />
<f32 x="-0%" y="92%" value="f32" />
</fkeyposition>
</a>
在MANIFEST.MF文件中指定jdom.jar
Class-Path: jdom.jar
就行了把jdom.jar解包,压缩到你制作的jar中也可以
http://hi.baidu.com/4472797074/blog/item/eb0d26fae1244e1aa8d31188.html