Launching jar file on Azure virtual machine - java

I am developing a java server-like application (though it is not a server itself, more like a bot for social network) and I decided to use Azure virtual machine to deploy the app on. So I've chosen Ubuntu virtual machine. I successfully uploaded .jar file on server, connected to it with Bash shell for Windows and SSH (as described in manual for Azure). Then I am able to launch my file with java -jar server.jar and it works. But the problem is that when I close the shell on my home computer, the app shuts down on the server too. So my question is how to launch .jar file in the way where it won't exit once I close SSH session?

Run the command in the background with nohup:
nohup java -jar server.jar &

Related

AWS ec2 web app goes down when command prompt is closed

I ssh into the ec2 instance using command prompt. I then launch the jar file from there. The web app runs perfectly from any device until the command prompt is closed. The site immediately goes down. The instance is shown as “running” when the site is down. ideas?
Well, ec2 is the virtual machine and it will show as running because you didn't shutdown or terminate it.
Your webapp is down because closing the command prompt will quit the shell session and thus terminating/killing the running jar.
It seems you are not running the jar as a background process.
If you are using Linux EC2 instance then try running your jar as
$java -jar jarfilename.jar &
The & makes your java process as a background job.
Note down the process id and then close the session. Now your webapp will keep on running as long as your ec2 instance is running.
I'd suggest reading about nohup and background processes in Linux in general.

Run a jar file permanent on v-server

I just bought a vserver and now I'm trying to run a jar file on it permanently.
The problem is, that if I connect to my vserver via PuTTY, the sessions ends when I close the program and that kills my program. How can I open a terminal sessions where I can run my jar file and which never stops? I'm running Ubuntu 20.04 on my server
Try the following:
nohup [your command and parameters] &
nohup is a unix command that means 'no hangup', so it won't kill the session when you disconnect.
The & means 'run this command as a background process'. That will let you disconnect without having to kill the program.
Here's more info on nohup : https://en.wikipedia.org/wiki/Nohup
In the longer-term you'll likely want to install the app as a service to start when you reboot the machine. The way to do so will depend on the flavor of unix/linux you have.
Best of luck!
Use nohup, screen, tmux or create a systemd service unit.

run a jarfile in a different machine from an sqlserver/issue a terminal command from an sqlserver to another windows machine

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

Pulling files from remote system using java Runtime.exec on mac

All along I have been pulling the remote files using the Runtime.exec() first by connecting the windows remote machine using "use net.." and then pulling the required files. Now I have a new mac machine and I am unable to connect to that windows remote using java code. I can access the server from finder window using below command:
smb://userName:password#ipAddress/pathToFileOnRemote
but when I run this command in java code using the Runtime.exec() method, I get an error stating No such file or directory.
Is there a different way to access the file on the windows remote from mac as compared to windows?

Unable to access jarfile on server using VNC

I'm trying to run a java application on a server computer by using VNC (tightVNC).
I have the java application in eclipse and it runs perfectly. Then I export it to a runnable jar file and upload the runnable jar file to the server. Now I'm trying to run the application (called ABUN_0.0.0.jar) using VNC.
I use /u01/gatc/java/jdk1.6.0_10/bin/java -jar ABUN_0.0.0.jar& (I've used this for previous versions of the app and its worked perfectly). However now I get Unable to access jarfile ABUN_0.0.0.jar
instead of
/u01/gatc/java/jdk1.6.0_10/bin/java -jar ABUN_0.0.0.jar&
use this,
/u01/gatc/java/jdk1.6.0_10/bin/java -jar /**path to jar**/ABUN_0.0.0.jar &
or
if Linux System,
check ABUN_0.0.0.jar's permission level.
To give Permission,
chmod 755 /**path to jar**/ABUN_0.0.0.jar

Categories

Resources