Vscode + Gradle Create Java project-Java language server cannot start

Source: Internet
Author: User

1. Install a version of Gradle on the system and create a default Java project with ' Gradle init--type java-application ', assuming the project directory is Hellojava

2, Vscode write Java first to install Java Extension Pack (hereinafter referred to as JEP), this extension will come with two dependencies installed, one is debugger for Java, and a language support for Java by Red Hat, These are Java language support implemented using Eclipse's JDT

The Hellojava folder is then added to the Vscode workspace, Jep automatically recognizes the Gradle project and integrates the project into JDT via Vscode, and the following event indicates that it is correctly identified:

2.1, in the status bar will see starting Java Language Server ... and successfully went to 100%, this step Jep according to your Gradlew (under Windows is gradle.bat) download the corresponding version of the Gradle (only for the Java project, not the system global)

2.2, Hellojava in the same directory with Build.gradle appeared. Project and. classpath files (something in eclipse), stating that Jep has used JDT to correlate your Gradle Java project.

2.3. Hellojava in the same directory with the Build.gradle Bin folder, which is your src in the Java file corresponding to the class file, indicating that Vscode has used Jep downloaded Gradle help you build the project (yes, you do not have to play the gradle manually Build command, automatic build), but note that here Vscode Jep using Gradle will only help you generate a class file for debug (you just need to edit your Java file and press F5 for debug), not equivalent to the Gradle build command , the Gradle Build command will also help you do unit testing, package jars, and so on, and you can manually knock Gradle build into the build directory instead of the bin directory. Bin directory of Things is Vscode press F5 debugging time to find the class file, and the build directory is the class file Gradle run, you should pay attention to the difference

3, recently found through the Deb package installed Vscode suddenly unable to correctly build and debug Java project, the following symptoms (not necessarily occur at the same time):

3.1. The class file in the bin directory cannot be synchronized with the Java file in src, the Java file is modified, and the class file appears to have not been recompiled

3.2. The class file in the bin directory disappears

3.3, F5 start the project error, the main idea is: Can't find the Master class

3.4, "output" inside found Jep error, the main idea is unable to install Gradle from Gradle.4.x.bin.zip (explain the steps in #2.1 failed), while opening the project Java file, the status bar has a thumbs down (contempt gesture), click and jump to "output "Error interface; Here's another way to tell you that you can't sync the status of your project, but it also means that jdt can't sync your gradle project.

4, I estimated that the problem described in # #, is estimated to be due to permissions issues, Jep Unable to successfully install Gradle and start the Java Language Server, why so to say, because the Deb package installation is to enter sudo password, installed in the/usr/ Share directory, while the boot Vscode is not used with sudo

4.1, test a bit, sudo start vscode, will not appear in the problem, but the problem is not sudo can not use Vscode

4.2, then the solution is to install Vscode to/home directory, without the Deb package installation, download the tar.gz package directly to the/home directory, so there is no permissions problem

Note: In fact, I started with the Deb package installed Vscode write Gradle Java project is also good, did not appear above the so-called "permissions Problem", but yesterday did not know what the wind suddenly can not be used, toss half a day to follow the above steps to solve, really fun to pull eggs

Vscode + Gradle Create Java project-Java language server cannot start

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.