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

How to run java program in sublime

下次还敢
Release: 2024-04-03 16:12:17
Original
658 people have browsed it

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>
Copy after login

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>
Copy after login
  • 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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template