How to deploy a java jar file to remote server through cmd

A combination of these two questions will probably be what you need:
  1. Copy a local file to the remote server using cmd
  2. Run remote command via ssh using cmd

1. Copy a local file to the remote server using cmd

Copying one single local file to a remote destination
scp /path/to/source-file user@host:/path/to/destination-folder/
So, if you wan to copy the file /home/user/table.csv to a remote host named host.example.com and copy there to jane's home folder, use this command.
scp /home/user/table.csv jane@host.example.com:/home/jane/
2. Run remote command via ssh using cmd
The tool on Linux for connecting to a remote system using SSH is called, unsurprisingly, ssh.
The most basic form of the command is:

ssh remote_host
The remote_host in this example is the IP address or domain name that you are trying to connect to.
This command assumes that your username on the remote system is the same as your username on your local system.

If your username is different on the remote system, you can specify it by using this syntax:
ssh remote_username@remote_host
After that Run this command: 
$ java -jar example-1.0-SNAPSHOT.jar
For maven related project:
$ java -jar /path/to/source-file server /path/to/config-file
Example:
$ java -jar target/example-1.0-SNAPSHOT.jar server src/main/resources/config.yml

Comments