Sublime Text can run Java programs by installing Java plug-ins: 1. Install plug-ins; 2. Configure Java environment; 3. Write Java programs; 4. Press F5/⌘ B to run the program and select "Java" as Build System; 5. Shortcut keys can be set (optional).
Running Java in Sublime Text
Sublime Text is a popular text editor that can be installed by installing the Java plug-in to run Java programs. Here are the detailed steps:
1. Install the Java plug-in
2. Configure Java
After installing the plug-in, you need to configure the Java environment:
{ "java_sdk_path": "/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home" }
Replace/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
with the Java SDK path .
3. Write a Java program
In Sublime Text, create a new file and save it with the.java
file extension. For example:Test.java
.
public class Test { public static void main(String[] args) { System.out.println("Hello, world!"); } }
4. Run a Java program
To run a Java program, do the following:
5. Set Java shortcut key (optional)
In order to run Java programs more conveniently, you can set a shortcut key:
{ "keys": ["ctrl+enter"], "command": "build" }
Now, press Ctrl Enter to compile and run the Java program.
The above is the detailed content of How to run sublime test java. For more information, please follow other related articles on the PHP Chinese website!