2012-06-26 102 views
0

我基本上有一個程序,使用apache poi將記錄從一個excel文件過濾到另一個excel文件。使用netbeans運行時,我的程序運行良好。但是,在執行clean and build並雙擊dist文件夾內的.jar文件時,它會運行很長時間(太長!),並給我出現以下錯誤(通過從命令提示符運行程序得到)。outofmemoryerror當運行jar時,但不在netbeans/apache poi中運行

有什麼解決辦法嗎?在清理和建設之前,我已經將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) 

回答

2

'-Xms1500m'標誌是運行時標誌,而不是編譯時標誌。你已經在Netbeans中設置了它,所以當你運行Netbeans時它只會得到這個標誌。

當你運行該程序在NetBeans外部,你需要像這樣運行:

的java -Xms1500m -jar [這裏你的程序。

+0

我如何設置它,讓我雙擊jar文件,然後它會像那樣運行它?非常感謝! – Laughy

+1

我認爲你可以用批處理文件去。雙擊批處理文件將運行你的項目。 – Zombie

+0

謝謝,該批處理文件與一個VBScript腳本文件結合在一起,隱藏了cmd窗口,完美地工作! – Laughy

相關問題