Run Java Console Application

Java Console Application with CentOS VPS

This tutorial demonstrates how to deploy a simple standalone Java console application on a CentOS Elastic VPS, upload the application archive, start it over SSH, and verify that it is accepting connections on the configured port.

Deployment Workflow

1. Install JavaPrepare the CentOS VPS with a Java runtime.
2. Upload ApplicationPackage the application as a JAR and transfer it to the VPS.
3. Run via SSHStart the JAR from the command line.
4. Test the PortConnect to the application port and verify the response.

Install Java on the VPS

Connect to the CentOS VPS over SSH using either the platform SSH Gate or the node’s public IP address.

1Download the required Java package

Use wget with the URL of the Java package you want to install:

wget {utility_address}

Replace {utility_address} with the appropriate Java download URL.

The source tutorial uses an older Oracle Java RPM download flow that required an authorization parameter confirming acceptance of the Oracle license. For a current deployment, use a Java package source and licensing method appropriate to the Java version you are installing.
Download Java package on CentOS VPS
Download the Java installation package from an SSH session.

2Install the downloaded RPM

rpm -ivh {java_rpm_package}

Replace {java_rpm_package} with the downloaded RPM package name.

Install Java RPM on VPS
Install the downloaded Java RPM package.

3Verify the Java installation

java -version
Check Java version on VPS
Confirm that Java is installed and available from the command line.

Upload the Java Application

Prepare the standalone Java application as a .jar archive. The source example uses an application named vdssocket.jar that listens for incoming connections on port 7777 and returns the request time and remote address.

1Connect with a file-transfer client

The source uses WinSCP. Connect to the VPS with the credentials received after server installation.

  • Host name — the attached public IP address.
  • User name — the VPS login, typically root in the source example.
  • Password — the password received after VPS provisioning.
Connect WinSCP to VPS
Connect to the CentOS VPS from WinSCP using the public IP and server credentials.

2Create an application directory and upload the JAR

Navigate to the VPS home directory, create a folder named standalone_java, and upload the JAR archive into it.

Upload standalone Java application to VPS
Upload the application JAR into the newly created standalone_java directory.

Access and Run the Application via SSH

1Open the application directory

cd /home/standalone_java/
ls

Confirm that the application JAR is present.

Standalone Java application directory
Verify that the uploaded JAR exists in the application directory.

2Start the application

java -jar vdssocket.jar

In the source example, the console confirms that the socket listener is active on port 7777.

Run Java application on VPS
Start the standalone Java application and confirm the listening port.
Production note: The tutorial starts the Java process interactively from an SSH session. For a long-running production application, use an appropriate service/process-management approach so the process survives SSH disconnects and can be restarted automatically.

Check Application Operability

The source tutorial tests the listener with a Telnet client. Connect to the VPS public IP and the port used by the Java application.

o {public_IP_address} {port_number}
  • {public_IP_address} — the external/public IP attached to the VPS.
  • {port_number} — the port where the Java application is listening, 7777 in the example.
Test Java VPS application with Telnet
Connect to the application through the VPS public IP and listener port.

If the application is working correctly, the client receives information that includes the request time and the remote address.

Java application Telnet response
The sample application returns the request time and remote-address information.

Switch back to the SSH session. The Java console should report that a new client has connected and display the client’s remote address.

Java VPS new client connection
The server console confirms the incoming client connection.
Deployment summary: Install Java on the CentOS VPS, upload the application JAR through a file-transfer client, start it over SSH with java -jar, and test the listening port through the VPS public IP.

What’s next?