I am calling a C process from my Java program, and ending that C process using exit (0).
On Windows machine, under certain conditions it is opening a pop-up window telling me that
"Test.exe has encountered a problem and needs to close. We are sorry for the inconvenience."
Does anyone have a guess why this problem is coming around? I want a clean shutdown without any window being opened.
I have used below alternatives also to close, with the same result:
exit(EXIT_SUCESS);
and
return 0;
The exit or return isnt likely to be the issue - the problem is a memory overrun etc. within the exe. You need to debug that when the problem happens.
Related
Recently, when I go to run a java program with the command java and then hit tab to autocomplete the .class file it just freezes. I have to hit control+c to kill it and I get the message Killed by signal in _java_class after 4s. I have tried googling but can't seem to find anything on it. javac + tab works as expected.
This problem is not related to Java at all. As you state it, the JVM has not even been started. Try to figure out what your shell is trying to do when you hit the tab key for autocomplete.
I guess it might even go scanning the filesystem for a suitable main class and whilst at that running into all kinds of trouble.
I am writing a simple program in Java, and sometimes it randomly freezes and does not respond. when I try to end it with Ctrl-C instead of quitting, the program springs back to life and starts working fine again. I am not posting my code because I have noticed this behavior with other command line programs on Windows, so it does not appear to be anything specific to my code. The program will eventually be running 24/7 on a headless server, so you can see why it would be a serious issue if it just stopped working every now and then. Thanks in advance. Any help is appreciated.
This sounds a bit like perhaps a selection issue: If you make a selection in the console window, it freezes console output. The next time an application attempts to flush to the console it will stall until the selection is cleared. Pressing ctrl-c will copy the selection and clear it, allowing the flush to complete and the application to continue to run. Any keypress in the console window should clear the selection though, and it sounds like only ctrl-c is working for you.
If that's not what the issue is, your next best bet the next time you see this would be to open up a native debugger (e.g. Windbg) or a java debugger and attach to the process you're running in the console process to see what is doing the waiting. It's likely that something you're calling is triggering a spurious getch / readline / etc. A debugger should make the source of the stall obvious. If you need help deciphering the stack once you have one, I might be able to help. Just paste it into this thread.
Ben
I own a game server and I was just wondering, instead of running the server in eclipse and then when I restart it, it opens a new cmd prompt outside of eclipse and runs the server on that. Could I make it so the program relaunches in eclipse as if I hit the green play button?
I was reading your comments on this post. You said that you don't want to kill the program and then restart from within eclipse. So you have two options.
Bad Answer: Just press ctrl + F11 (relaunch the application and ignore the old one)
Good Answer: Press F11 then go to what looks like a computer in the console tab. You can select the previous running program and kill it and the second one will still be running.
If what you want to do is transfer the data and keep it the same run time state, well to say the least that is going to be some what complex. I would make some kind of method to transfer all current data and call it from your constructor. Then start your second program and kill the original. I'm 90% sure all your users will get booted though.
I have a Java application launched via Webstart. About half the time, this program will not die. This program listens on a socket and when it receives a particular command, should close down. When it receives this command, it prints out what it normally should to the java console (that it received the shutdown command), the Java console closes, all the windows close, but the java process continues to run.
I have tried switching System.exit(0) to Runtime.getRuntime().halt(0) with no success - the same problem happens (my initial thought was a shutdown hook was affecting it).
Furthermore, when I have VisualVM connected to the Java process, it also indicates that it loses the connection when halt or exit are called, and I cannot reconnect, but the java process continues to exist.
Any ideas on how I could solve this? I've tries wrapping the program in try { } and exit/halt in finally { } to ensure nothing was holding it up, tried halting instead of exiting, etc...
My only thought is Java could be retaining a system resource (file handle to socket or something) or be stuck in a system call so the system won't let it quit - but the Java console closes, which to me seems like an indication the VM is trying to shutdown...
Any thoughts or ideas are appreciated!
My programs in netbeans do not terminate as they are done with execution but continue running on as Running Tasks appearing at the right bottom corner of the netbeans window. Each time I re-run my same program a new thread is added to the 'Running Tasks' even when the code is done with execution.
Why is this caused ?
How can I rectify this ?
This is an extremely old question but I stumbled upon this having the same issue. Here is how I solved it:
Close NetBeans, delete the NetBeans folder from C:\Users\[your username]\AppData\Roaming\, then restart NetBeans. WARNING: this will delete any specific settings you've set (i.e. font size/style, etc) so beware of that before trying this
It seems one of the User Thread is running, post code to get the exact answer
Your programming is not exiting correctly. If it is a GUI make sure your main Frame is set to Exit on close, or that at least something is set to exit when the frame is closed.