Home  >  Article  >  Development Tools  >  How to run java program in sublime

How to run java program in sublime

下次还敢
下次还敢Original
2024-04-03 16:12:17565browse

How to run Java programs in Sublime

Step 1: Configure Java Development Kit (JDK)

  • Download and install JDK, available from the Oracle website.
  • Set the JAVA_HOME environment variable to point to the JDK installation directory.

Step 2: Install the Sublime Text plug-in

  • Open Sublime Text.
  • Press Ctrl Shift P to open the command panel.
  • Enter "Package Control: Install Package" and press Enter.
  • Enter "Java Package" in the search box, find and install the Sublime plug-in.

Step 3: Create a Java Project

  • Create a new file (.java) in Sublime Text.
  • Copy and paste the following code into the file and save it as Main.java:
<code class="java">public class Main {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}</code>

Step 4: Configure compilation options

  • Go to Preferences >Settings.
  • In the "Additional Settings - User" section, add the following:
<code class="json">{
    "java_jdk_path": "/path/to/JDK_HOME",
    "java_args": ["-classpath", "${folder:.}"]
}</code>
  • Replace "java_jdk_path" with the JDK installation directory.

Step 5: Run the Java program

  • Press Ctrl B to compile and run the Java program.
  • The program will output the results in the console of Sublime Text.

The above is the detailed content of How to run java program in sublime. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn