1

當從其他Java程序運行此語句時。InvocationTargetException,從此異常中提取異常消息

mainMethod.invoke(null,(Object) args); 

我通過JVM給這個異常

I'm dying! 
I'm not dead yet! 
java.lang.reflect.InvocationTargetException 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 
at com.fourgid.ot.action.RunThread.run(RunThread.java:59) 
***Caused by: java.lang.SecurityException 
at Main$1.checkExit(Main.java:21) 
at java.lang.Runtime.exit(Runtime.java:88) 
at java.lang.System.exit(System.java:904) 
at Main.main(Main.java:30)*** 
... 5 more 

我只是爲了證明不僅造成異常是SecurityException與消息和行號(上文所強調的文本)。

我正在開發一個編譯應用程序並在web上執行程序。

謝謝!

+1

1)*「請幫助我!」*請提出一個問題和解決方案卡住'!'鍵。 *「Thanx!」*請正確拼寫「謝謝」等字樣,或者更好地留下這種噪音。 2)[你有什麼嘗試?](http://www.whathaveyoutried.com/)。在這種情況下,我建議[SSCCE](http://sscce.org/)。 –

回答

2

我的建議:趕上InvocationTargetException,然後嘗試exception.getCause()。您可能會從底層SecurityException獲得更多詳細信息。