0

我基本上有一个程序,它使用 apache poi 将记录从一个 excel 文件过滤到另一个 excel 文件。我的程序在使用 netbeans 运行时运行良好。但是,在进行清理和构建并双击 dist 文件夹中的 .jar 文件后,它运行了很长时间(太长了!)并给了我以下错误(我是通过从命令提示符运行程序得到的)。

有什么解决办法吗?在清理和构建之前,我已经在 netbeans 中将堆大小增加到 -Xms1500m。

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    at org.apache.xmlbeans.impl.store.Saver$TextSaver.resize(Saver.java:1592)
    at org.apache.xmlbeans.impl.store.Saver$TextSaver.preEmit(Saver.java:1223)
    at org.apache.xmlbeans.impl.store.Saver$TextSaver.emit(Saver.java:1144)
    at org.apache.xmlbeans.impl.store.Saver$TextSaver.emitElement(Saver.java:926)
    at org.apache.xmlbeans.impl.store.Saver.processElement(Saver.java:456)
    at org.apache.xmlbeans.impl.store.Saver.process(Saver.java:307)
    at org.apache.xmlbeans.impl.store.Saver$TextSaver.saveToString(Saver.java:1727)
    at org.apache.xmlbeans.impl.store.Cursor._xmlText(Cursor.java:546)
    at org.apache.xmlbeans.impl.store.Cursor.xmlText(Cursor.java:2436)
    at org.apache.xmlbeans.impl.values.XmlObjectBase.xmlText(XmlObjectBase.java:1455)
    at org.apache.poi.xssf.model.SharedStringsTable.getKey(SharedStringsTable.java:130)
    at 

org.apache.poi.xssf.model.SharedStringsTable.addEntry(SharedStringsTable.java:176)
    at org.apache.poi.xssf.usermodel.XSSFCell.setCellType(XSSFCell.java:755)

    at equity.EquityFrame_Updated.copyRowsFromOldToNew(EquityFrame_Updated.java:646)
    at equity.EquityFrame_Updated.init(EquityFrame_Updated.java:133)
    at equity.EquityFrame_Updated.createAndShowGUI(EquityFrame_Updated.java:71)
    at equity.EquityFrame_Updated.<init>(EquityFrame_Updated.java:50)
    at equity.FileOpener.generateButtonPressed(FileOpener.java:160)
    at equity.FileOpener.access$100(FileOpener.java:17)
    at equity.FileOpener$2.actionPerformed(FileOpener.java:61)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
4

1 回答 1

2

'-Xms1500m' 标志是运行时标志,而不是编译时标志。您已在 Netbeans 中设置它,因此只有在您通过 Netbeans 运行时它才会获得该标志。

当您在 Netbeans 之外运行程序时,您需要像这样运行它:

java -Xms1500m -jar [你的程序在这里]。

于 2012-06-26T03:11:28.420 回答