Exception Handleing

I’m writing my jMonkeyEngine game in JRuby, and when I get an exception error, the application stays open, but doesn’t allow me to exit when I hit esc, or crt+c, ect… The only way I’m able to close it is to Force Quit the application.



Is there an easier way to do this? Or is there a way to set a “close application on all errors” config?



~Jeremy

I guess I should mention that this is on OSX as well.

Why don’t you treat the exception?

[java]

try{

//do something here

}

catch(Exception ex) {

//treat the exception here

}

[/java]



Try to add “System.exit(0);” in catch.

Yes, ultimately that would be the goal. The issue right now is I’m just learning jMonkeyEngine, and there was an example where I was going through the tutorial, and it had me use the Unshaded.j3md in my material. I didn’t know what that was, so I switched it out with another .j3md file to see what would happen, and an exception happened. I guess I could just throw every single line of code into an exception block, but I was trying to avoid riddling my code with all this stuff just to learn the system.



On a side note, I’m using JRuby and not Java directly :wink: Thanks for the advice!





~Jeremy

You can quit the running application by pressing the “x” in the progress bar showing the process status in the lower right. It should work even if the Application hung.

Well, I’m not actually using the platform application, I’m just building this and running it from the console, but I’ll try that out :slight_smile:



Thanks!



~Jeremy

if you use any kind of ide, it usually has a terminate button.



The exception probably comes, because the j3md (Thats a material template, I suggest you look in the wiki for material if you want to read more about this) you tried to use has different paramters, and so the setting faild.

Running from console? Just press Ctrl-C ?

You can handle any exceptions by overriding handleError() method in Application. In there you can call System.exit() for example …