I'm executing a java application through a .bat file and it's executing as well. But sometimes the console stops to show the logs (The process is stopped) and pressing enter in the console the process returns its execution. The program doesn't need user interaction and the problem occurs randomly.
I can't put prints here because the network is closed.
I've tried to set thread priorities to MAX_PRIORITY and no success.
The application is running on Windows 10 x64, and JRE 1.8.
The script into .bat is:
java -Dfile.encoding=UTF8 -jar myapplicationname.jar
Related
I have a .bat file which has command to run a Java console program.
I created windows scheduler task to invoke the bat file.
When I run the windows task then it invokes the java program, but when I stop the windows task (Right click the task, Select option End) then my java program do not stop.
My question is how to stop an external program which got started from the bat file. Is there way to capture the End event/signal from task which can be passed to bat file or java program to stop the program.
I got similar question here https://superuser.com/questions/1054534/stopping-a-scheduled-task-with-a-batch-file-action-doesnt-stop-the-program-runn
but it is unanswered.
Atul
I am using a Windows executable to do some optimisation tasks. This executable is run from a Windows Command Prompt (cmd). It reads a batch file that tells it how to run a model interface (it will need to run it multiple times) which reads and writes text files for input/output between it and the optimisation .exe program. This model interface is written in java and has been successfully compiled. My batch file looks like this:
java -cp .;"C:\Program Files\location_of_required_jars\*" name_of_class_file
The java program executes and completes without issue.
My issue is that the executable I am running needs to know when java has terminated. At the moment it hangs after 1 run of the model interface java program, waiting for the java ... line to complete.
Can anyone provide advice on how to get java to inform cmd that it has completed?
If the batch file does not progress further after running first java command that means that java process has not actually finished. You would need to diagnose the problem, I would suggest to first make sure that it indeed does not finish by adding some echo statement after java invocation. Next you would need to run jps command, which is part of JDK. jps will report PIDs of running java processes and then you do jstack <pid> to find out what is preventing your java program from terminating. It can be that main thread did not actually complete or some non daemon threads are still running.
I have a java program (text-based no GUI) that I have written and compiled and uploaded to a server.
I run it with java -cp myjar.jar mypackage.MyClass which starts it running processing a datafile with 20,000,000+ entries in it and printing output to System.out. I have calculated that it will take a very long time to process the data and I didn't want to have my laptop open for the 10 days of number crunching...
When I log out of my shell however, the process stops.
How can I execute the command and log out without it stopping? What is that even called?
I am using an Amazon Ubuntu EC2 server. I log in using a certificate from Mac OSX with terminal. The server seems to be using a bash shell.
Hope someone can help me out!
Jason.
Consider using screen instead of nohup. It allows you to create a virtual terminal that persists even after you logout/disconnect. When you reconnect to the server, you can immediately jump into the screen session you last had open.
Typical workflow on the server:
type screen (you may need to press space to leave intro page)
type in your command that you want to leave long-running (your java program, or an OS upgrade)
press ctrl a+d to leave screen (make sure to hold ctrl down)
To re-enter screen just use screen -r, and you will see the previous terminal and any running programs as you left it.
You can use nohup
nohup java -cp myjar.jar mypackage.MyClass > yourLogFile.log &
-----> http://ss64.com/bash/nohup.html
I have developed an application that reads and writes register values from a device (meter).
I have created a .jar file of this application and ran it in the command prompt.
I have used the following command for execution:
java -jar -Xmx20m -Xms10m ReadWriteDev.jar
But after 2-3 hours it terminates. What is the reason for this?
I ran the jar file successfully from the command prompt, and i see the beanshell 2.0 with a jellybean face small window being loaded. and then it seemed to have froze while loading.
Am i missing something, and this is from the latest beta stable jar file from here
after running C:\>java -jar C:\Java\jdk1.6.0_26-32\jre\lib\ext\bsh-2.0b4.jar for about 20 times, the splash page stopped freezing, and the GUI console is launched. Opening a new command prompt and running the command doesn't seem to guarantee the GUI console will run again.
Otherwise, I found that running java -Xrs -Xverify:none -cp bsh-2.0b4.jar bsh.Interpreter in the command prompt is far more effective and works all the time.
I had this on windows 10 after launching Beanstalk from Chrome. I couldn't find the process to terminate, but I just ran the bsh-2.0b4.jar file again and it works!