Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deploy/debug java code on a remote server using Intellij

I want to run my java code on a remote server for faster speed (The server is very powerful). What I want is to connect my Intellij to that remote server and run my code. But I want to still use the IntelliJ on my local machine (i.e. my laptop).

I found a config section in IntelliJ which is in Default Setting->Build-executation-deployment-> Deployment and there I can set the address of my remote server and username and password. But I don't know what to do next.

like image 636
HimanAB Avatar asked Feb 22 '17 00:02

HimanAB


People also ask

How do I debug a Java program remotely?

Go to the eclipse menu and select Run->Debug Configuration; it opens Debug Configuration setup. On the Debug configuration window, create a new “Remote Java Application” configuration. Select the project to be debugged and give it a Name. Select connection type, Socket Attach, or Socket Listen.

How do I connect to a remote server with IntelliJ?

Connect via SpaceLaunch IntelliJ IDEA. On the starting page, select JetBrains Space and click Connect to Space. Enter your organization URL and click Continue in Browser. In the browser window that opens, click Accept to grant the required permissions.

What is remote debugging in IntelliJ?

Remote debugging gives developers the ability to diagnose unique bugs on a server or another process. It provides the means to track down those annoying runtime bugs and identify performance bottlenecks and resource sinks. In this tutorial, we'll take a look at remote debugging using JetBrains IntelliJ IDEA.


1 Answers

There is a step by step deployment guide for PhpStorm, but for IntelliJ IDEA it would be almost the same.

Here is the example configuration for deploying a .jar file from artifact subdirectory to the remote server via SFTP into /home/serge/artifact directory:

connection

mappings

I'd configure the artifact to produce the executable jar. Then adjust the deployment configuration to deploy the jar to the remote server. Or you can use Maven/Gradle to do the same.

Next, you can configure Remote SSH external tool to run the jar on the server (via java -jar jarname.jar:

remote ssh tool

Running on the remote server via Tools | External Tools | hello:

running

To automate the process enable Include in project build for the artifact, enable Automatic upload in Tools | Deployment and enable uploading of external changes in Tools | Deployment | Options.

To debug the code use Remote Debug configuration. Copy the JVM options needed for debug and adjust the options in your remote SSH external tool so that the app is started in debug mode and can accept connections (make sure firewall rules are adjusted to permit the connections on the specified port).

  • remote debug configuration
  • debug external tool configuration
  • proof of working
like image 80
CrazyCoder Avatar answered Oct 25 '22 02:10

CrazyCoder