Vs code remote, develop programs on the server and start a new development mode

I've been using idea to develop java programs. The headache is that my wife takes up too much memory. Laptops often jam. It's too troublesome to develop servers. Vs code remote solves this problem. Let's practice.

VS Code Remote

On May 3, 2019, at the pycon 2019 conference, Microsoft released vs code remote, opening a new era of remote development.

Visual studio code remote allows developers to use containers, remote computers, or windows subsystem for Linux (WSL) as a complete development environment. You can:

All of the above features do not require source code in your local development environment. Through vs code remote, you can easily connect to the remote environment and develop locally.

Let's practice.

Install vs Code insiders

You need to install the latest internal experience version first, https://code.visualstudio.com/insiders/

Then install the remote development plug-in

https://marketplace.visualstudio.com/items?itemName=ms -vscode-remote. vscode-remote-extensionpack

For simplicity, we use SSH mode. You need to install openssh on the windows machine first

Installing openssh for windows 10

Installing openssh using PowerShell

To install openssh using PowerShell, first start PowerShell as an administrator. To ensure that openssh functionality is available as an installation:

PowerShell replication

Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

# This should return the following output:

Name  : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name  : OpenSSH.Server~~~~0.0.1.0
State : NotPresent

Then, install the server and / or client features:

PowerShell replication

# Install the OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0

# Install the OpenSSH Server
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

# Both of these should return the following output:

Path          :
Online        : True
RestartNeeded : False

SSH authentication

 ssh-copy-id root@YOUR-SERVER-IP
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/c/Users/jqpeng/.ssh/id_ed25519.pub"
The authenticity of host 'YOUR-SERVER-IP' can't be established.
ECDSA key fingerprint is SHA256:HRwsmslg5ge+JYcOjW6zRtUxrFeWJ5V2AojlIvLaykc.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s),to filterout any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted Now it is to install the new keys
root@YOUR-SERVER-IP's password:

Number of key(s) added: 1

Now try logging into the machine,with:   "ssh 'root@YOUR-SERVER-IP'"
and check to make sure that only the key(s) you wanted were added.

Develop programs using vs code inside

preparation:

Open vs code, command line:

Select connect to host:

Then enter root@YOUR_SERVETR_IP

Press enter, and vs will automatically prepare the relevant environment on the server.

After that, click file to open the folder, vs code will list the directory of the server, and select the address where the project is located to open it.

Next, install the necessary language plug-ins and open a java file. Vs code will automatically install some plug-ins to install Java related plug-ins:

Debugging program

Open the java file containing main, click the debug menu, and a startup file will be automatically generated, which can be configured as follows:

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0","configurations": [
        {
            "type": "java","name": "AimindWebApplication","request": "launch","mainClass": "com.xxx.xxx.XXXWebApplication"
        }
    ]
}

Then start.

I was surprised to find that run|debug automatically appears above the main function, as shown in the figure below. Click debug to start debugging

You can see the corresponding output in the debugging console.

Memory usage

Before, after idea started debugging, the memory occupied 2G +, what about vs Code? 400M+!

All the computing resources and memory are put on the server for execution. The local only needs to be responsible for the view, so the resource occupation is very small.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>