1
我可以在一個jar文件之外運行我的程序,但我想部署它並以jar的形式運行它。爲什麼我的jar沒有運行?
該命令適用於運行.class文件:
java -classpath .;./libs/mail.jar;./libs/jcommon-1.0.16.jar;./libs/jfreechart-1.0.13.jar;./libs/jxl.jar;./libs/ojdbc5.jar gdsreports/ReportsDriver
這是我打包我的jar文件:
jar -cfvm GDSReports.jar GDSReports.mf gdsreports/* util/* libs/*
我的清單看起來是這樣的:
Manifest-Version: 1.0
Main-Class: gdsreports.ReportsDriver
Created-By: Me
這就是我如何運行我的罐子:
java -classpath .;./libs/mail.jar;./libs/jcommon-1.0.16.jar;./libs/jfreechart-1.0.13.jar;./libs/jxl.jar;./libs/ojdbc5.jar;./util;./gdsreports -jar GDSReports.jar
但是,運行我運行jar文件,它無法加載所有庫。這是它吐出:
Error loading configuration file: config/reportConfig
Error loading configuration file: config/gdsIds
Exception in thread "main" java.lang.NoClassDefFoundError: jxl/write/WriteException
at util.ReportConfig.setupReports(ReportConfig.java:197)
at util.ReportConfig.setup(ReportConfig.java:65)
at gdsreports.ReportsDriver.main(ReportsDriver.java:36)
Caused by: java.lang.ClassNotFoundException: jxl.write.WriteException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more
這是預期的輸出:
Error loading configuration file: config/reportConfig
Error loading configuration file: config/gdsIds
-------------------------------------
Running TimingReport with parameters:
Filename: Reports/06-26-2012/TimingRptZL_06-26-2012.xls
Brand: ZL
Using production database: false
-------------------------------------
-------------------------------------
Exception in thread "main" java.lang.NullPointerException
at gdsreports.TimingReport.fillChartData(TimingReport.java:417)
at gdsreports.TimingReport.fillReport(TimingReport.java:238)
at gdsreports.TimingReport.run(TimingReport.java:131)
at gdsreports.ReportsDriver.main(ReportsDriver.java:40)
我在做什麼錯?
然後你做錯了。在描述您的嘗試的問題中添加一些細節。 –
我當時需要使用Class-Path而不是Classpath。定時器到期時接受。 – Malfist