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?
Related
I've want to start a JAR file through a service script file or normal bash script. If I try the following in the command line, it is working all great. The JAR file runs in background and also if I end the SSH session:
nohup /opt/java/jdk8_x32/jre/bin/java -jar /home/test/DoOnLANServerAgent_1.0.0-SNAPSHOT.jar &
If I use exactly the same from within a bash script file, the JAR wouldn't launch and the process is never running. This occurs also, if I use a normal service script in /etc/init.d/myservice. The process won't start, I always have to open up the terminal and manually start the Java program.
Is there any solution for my problem?
I have a series of stored procedures(say, SP1, SP2, SP3) consecutively running on an sqlserver(say, serverA).
After SP3 finishes execution, I want to run a jar file in some machine (say, computerA). Is there a way for me to trigger the run of my jar file in computerA after SP3 finishes executing in serverA?
Note: I can only run my jar file in computerA because my jar file actually retrieves data from Bloomberg API. So, this jar file needs to run in a machine that has Bloomberg terminal on it. Only computerA has a Bloomberg terminal.
I think another way of saying this is how to issue a terminal command from an sqlserver to another windows machine. Because I can just issue the following command to computerA but I really don't know how to make that possible.
java -jar D:\Runnables\myJavaApp.jar
I have Executed the gradle installDist task for my project. After that two start scripts were created one for running in unix like system and another for windows.
I am able to successfully execute the script created for unix systems. But when I tried to run the windows .bat file in my windows system. It is giving below error in command line.
Even if I am trying to run the batch file directly from cmd. It is giving the below error
The input line is too long.
The syntax of the command is incorrect.
php and batch files.
So i'm executing batch files through php
I have no issues launching the batch.
$str = exec('C:\WINDOWS\system32\cmd.exe /c START C:\MInecraft\_restart.bat');
However the issue im having is getting the batch file to work currectly. When the batch is run, it executes this code
taskkill /IM java.exe /F
java -Xmx1024M -jar craftbukkit.jar -o true
batch file successfully runs the taskkill command when launched with php, however it will not run the next line. When ran manually it launches fine, (bear in mind that the cmd.exe does not exit it stays open with this code)
Any ideas on how i can get this to launch from php?
Maybe the reason is the same as given at Error Executing Batch file of BlazeDS, the java executable is not found by Windows on running the batch file from within PHP script.
The current working directory or the directories listed in environment variable PATH can be different when the batch file is executed from within the PHP script in comparison to running the batch file manually.
Do you have ever tried to specify java.exe with full path in double quotes in the batch file?
You could also add at top of the batch file the commands
dir /w
PATH
to see which directory is the current directory and which directories are listed in environment variable PATH on execution of the batch file from within PHP script.
Forgot to post back here, I specified java through windows path command rather than the batch. The problem is because the java process takes the cmd and turns it into a console, it never finishes the batch file. So, the php never returns and continues the code unless the batch is force ably closed on the server.
pclose(popen("start /B C:\MInecraft\_restart.bat &", "r")); die();
I ended up using this command, which i believe makes it launch the batch and not wait for a reply. Just carry on with the php.
Thanks for your kind reply. I did initially try launching java in multiple ways.
I have a Java standalone project in Eclipse with about 10 packages. I have a main method(in eclipse) that when executed from Eclipse works fine.
I have written a batch file to run it from the desktop. I just click the batch file and hope to run the program.
My code for the batch file is as follows.
RunExecuteMyProg.bat
echo Output of the Program
echo ---------------------
java C:\eclipse_workspace\eclipse\myprogram\MainProgram\ExecuteMainProgram
echo "Program Executed"
This program when run in Eclipse, usually takes between 1 -4 min depending on a number of factors. But when I click the .bat file, it opens for a fraction of a second and closes. Java is on my classpath. At command prompt when I try to compile, I get compile errors saying that some class is not found. However on eclipse it just runs fine. Log files need to get created when this program runs, but nothing happens from batch file.
PS: The class files are created in the same folder as the source files.
You will know the problem if you open a command prompt and enter that command you have there:
java C:\eclipse_workspace\eclipse\myprogram\MainProgram\ExecuteMainProgram
It could be that you don't have java in the path or your program is written so that it has to have its current working directory where the program is located, etc etc.
Or any number of things. Get the output from executing that command manually in a command prompt.