简体   繁体   English

在 Sublime Text 2 中编译和运行 Java 代码

[英]Compiling and Running Java Code in Sublime Text 2

I am trying to compile and run Java code in Sublime Text 2. Don't just tell me to do it manually in the Command Prompt.我正在尝试在 Sublime Text 2 中编译和运行 Java 代码。不要只是告诉我在命令提示符中手动执行。 Can anyone tell me how?谁能告诉我怎么做?

Btw, I am on Windows 7...顺便说一句,我在 Windows 7 上......

Your path might not appear to work if you haven't referenced the correct folder - that set by step I posted way back only applied for that version of the JDK. 如果您没有引用正确的文件夹,那么您的路径可能似乎无法正常工作 - 通过步骤I设置的方式返回仅适用于该版本的JDK。

If you aren't seeing any menu when you right click on 'Computer' try this instead. 如果您在右键单击“计算机”时没有看到任何菜单,请尝试此操作。

For JDK version jdk1.7.0_07 Just update this with location of your JDK when a new version is released. 对于JDK版本jdk1.7.0_07 只需在发布新版本时使用JDK的位置更新它。

  • Click START 点击开始
  • Type "Path" (without the quotes) into the search area 在搜索区域中键入“路径”(不带引号)
  • You should see "Edit environment variables for your account" <--- click this 您应该看到“为您的帐户编辑环境变量” <---单击此按钮
  • A window should appear titled "Environment Variables" 应该出现一个标题为“环境变量”的窗口
    • Click TEMP on the top area 单击顶部区域的TEMP
    • Scroll a little bit on the bottom second area until you find Path 在底部的第二个区域滚动一点,直到找到Path
    • Select Path and click Edit... 选择Path并单击Edit ...
  • Paste this in at the very end of bottom text area 将其粘贴到底部文本区域的最末端

;C:\\Program Files\\Java\\jdk1.7.0_07\\bin

  • Make sure to OK out of both windows 确保两个窗口都没问题
  • Restart Sublime text if needed 如果需要,重新启动Sublime文本

That's all there is to it. 这里的所有都是它的。

So to actually get compiling and running your Java programs after completing the above, you will need to do the following. 因此,要在完成上述操作后实际编译并运行Java程序,您需要执行以下操作。 Just create a simple java class so you are on the same page as me 只需创建一个简单的java类,这样你就和我在同一个页面上

Building your Java class 构建Java类

  • Open a new SublimeText2 document and paste the following 打开一个新的SublimeText2文档并粘贴以下内容

     class hello { public static void main(String[] args) { System.out.println("Hello World!"); } } 
  • Then save that file to your Desktop - call it 然后将该文件保存到桌面 - 调用它

     hello.java 
  • you should have something like this 你应该有这样的东西 Java和保存的文件

  • Now press Ctrl+b on your keyboard to build your java class which should produce this! 现在按下键盘上的Ctrl + b来构建你应该产生这个的java类! 建立结果

Finally! 最后! - Running your Java program! - 运行Java程序!

  • You need to open a command prompt window, so go ahead and do that. 您需要打开一个命令提示符窗口,所以继续这样做。
  • Then navigate to the folder (in this case our desktop) where your java class is located 然后导航到java类所在的文件夹(在本例中为我们的桌面)
  • navigating using the command prompt is easy - just use 使用命令提示符导航很简单 - 只需使用即可

     cd <-- this stands for change directory dir <-- this will list everything in the current directory if you get stuck! 
  • in my case it looks like this 就我而言,它看起来像这样

dir和cd的例子

  • Cool, looks like we are in the right place. 很酷,看起来我们在正确的地方。
  • Finally type the following 最后输入以下内容

     java hello 

java你好结果

I hope this helps anyone who stumbles across this! 我希望这可以帮助任何偶然发现这个的人!

So this is what i added to the JavaC.sublime-build file所以这就是我添加到 JavaC.sublime-build 文件中的内容

{
    "cmd": ["javac", "-Xlint", "$file"],
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.java",

    "variants": [

        { "cmd": ["javac", "-Xlint", "$file"],
          "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
          "selector": "source.java",
          "name": "Java Lintter"
        },  

        { "cmd": ["java", "$file_base_name"],
          "name": "Run Java"
        }
    ]
}

What this does is that it creates variants to the regular build command ( ctrl+b ).它的作用是为常规构建命令( ctrl+b )创建变体。 With ctrl + b you will still be able to compile your code.使用ctrl + b你仍然可以编译你的代码。 If you do shift + ctrl + b the first variant will be executed, which in this case is javac with the -Xlint option.如果您执行shift + ctrl + b ,则将执行第一个变体,在本例中为带有 -Xlint 选项的 javac。 The second and final variant is the java command itself.第二个也是最后一个变体是 java 命令本身。 you can place this as your first variant and shift + ctrl + b will actually execute the java code.你可以把它作为你的第一个变体, shift + ctrl + b将实际执行 java 代码。

Also, notice that each variant as a "name".另外,请注意每个变体都是一个“名称”。 This basically allows this specific "build" option to show up in the shift + ctrl + p option.这基本上允许这个特定的“构建”选项显示在shift + ctrl + p选项中。 So using this configuration, you can simply do shift + ctrl + p and type "Run Java" and hit enter , and your code will execute.因此,使用此配置,您只需执行shift + ctrl + p并键入“运行 Java”并按回车键,您的代码就会执行。

Hope this helped.希望这有帮助。

I find the method in the post Compile and Run Java programs with Sublime Text 2 works well and is a little more convenient than the other methods.我发现使用 Sublime Text 2 编译和运行 Java 程序一文中的方法效果很好,并且比其他方法更方便一些。 Here is a link to the archived page. 是存档页面的链接。

For Windows:对于 Windows:

Step 1:第1步:

Create runJava.bat with the following code.使用以下代码创建runJava.bat

@ECHO OFF
cd %~dp1
ECHO Compiling %~nx1.......
IF EXIST %~n1.class (
DEL %~n1.class
)
javac %~nx1
IF EXIST %~n1.class (
ECHO -----------OUTPUT-----------
java %~n1
)

Copy this file to jdk bin directory.将此文件复制到 jdk bin 目录。

Step 2:第2步:

  1. Open Sublime package directory using Preferences > Browse Packages..使用 Preferences > Browse Packages 打开 Sublime 包目录。
  2. Go to Java Folder转到 Java 文件夹
  3. Open JavaC.sublime-build and replace line打开 JavaC.sublime-build 并替换行
    "cmd": ["javac", "$file"],
    with
    "cmd": ["runJava.bat", "$file"],

Done!完毕!

Write programs and Run using CTRL + B编写程序并使用CTRL + B运行

Note : Instructions are different for Sublime 3.注意:Sublime 3 的说明不同。

Sublime Text 3 has a slightly different solution. Sublime Text 3 有一个稍微不同的解决方案。 This is a modification of vijay's answer, which I was using before.这是对我之前使用过的 vijay 答案的修改。

 {
     "shell_cmd": "javac -Xlint \"${file}\"",
     "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
     "working_dir": "${file_path}",
     "selector": "source.java",

     "variants":
     [
          {
               "name": "Run",
               "shell_cmd": "java \"${file_base_name}\""
          }
     ]
 }

Paste the above into a new file called JavaC.sublime-build and put it into your User packages.将上述内容粘贴到一个名为JavaC.sublime-build的新文件中,并将其放入您的用户包中。 This can be found in C:\\Users\\You\\AppData\\Roaming\\Sublime Text 3\\Packages\\User .这可以在C:\\Users\\You\\AppData\\Roaming\\Sublime Text 3\\Packages\\User

Ctrl-B will compile. Ctrl-B 将编译。 Ctrl-Shift-B will run. Ctrl-Shift-B 将运行。

This version of JavaC.sublime-build which is edited from vijay's answer works for me on both Windows 7 and Mac for Sublime Text 3.这个版本的 JavaC.sublime-build 是从 vijay 的答案中编辑的,适用于 Windows 7 和 Mac for Sublime Text 3。

I edited it so Ctrl+b or command+b is sufficient for both build + run.我编辑了它,所以 Ctrl+b 或 command+b 对构建 + 运行都足够了。

{
"shell_cmd": "javac -Xlint $file && java $file_base_name",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
"shell": true
}

'&&' ensures that the second part runs only when first part succeeds ie only when the class file is generated. '&&' 确保第二部分仅在第一部分成功时运行,即仅在生成类文件时运行。 You can find more related info here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true您可以在此处找到更多相关信息: http : //www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true

compile and running as per documentation of sublime text 2 nd 3按照 sublime text 2 nd 3 的文档编译和运行

step- 1: set environment variables for java as u know already or refer somewhere第 1 步:为 Java 设置环境变量,因为您已经知道或参考某处

strp-2: open new document and copy paste code below strp-2:打开新文档并复制下面的粘贴代码

{
"cmd": ["javac", "$file_name", "&&", "java", "$file_base_name"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.java",
"shell":true }

step-3: save the document as userjavaC.sublime-build in directory C:\\Users\\myLapi\\AppData\\Roaming\\Sublime Text 3\\Packages\\User步骤 3:将文档保存为 userjavaC.sublime-build 目录 C:\\Users\\myLapi\\AppData\\Roaming\\Sublime Text 3\\Packages\\User

step-4:第四步:

after done select as tools->build systems->userjavaC完成后选择工具->构建系统->userjavaC

to both compile and run press ctrl+b编译和运行按ctrl+b

I am using Windows 7. The below solution works for me!!我使用的是 Windows 7。以下解决方案对我有用!!

**Open** the file JavaC.sublime-build and replace all the code in the file with the code below:

{
 "cmd": ["javac", "$file_name","&&","java", "$file_base_name"],
 "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
 **"path": "C:\\Program Files\\Java\\jdk1.6.0\\bin\\",**
 "selector": "source.java",
 "shell": true
 }

Remember to replace "C:\\Program Files\\Java\\jdk1.6.0\\bin\\" with the path where you put your jdk.请记住将“C:\\Program Files\\Java\\jdk1.6.0\\bin\\”替换为您放置 jdk 的路径。 And make sure to add the path of you java JDK to the environment variable "PATH".并确保将 java JDK 的路径添加到环境变量“PATH”中。 Refer to bunnyDrug's post to set up the environment variable.参考bunnyDrug的帖子设置环境变量。 Best!!最好!!

Refer the solution at: http://www.compilr.org/compile-and-run-java-programs/参考解决方案: http : //www.compilr.org/compile-and-run-java-programs/

Hope that solves, for both compiling and running the classes within sublime..... You can see my script in the comments section to try it out in case of mac...希望能解决,在 sublime 中编译和运行类......你可以在评论部分看到我的脚本,在 mac 的情况下尝试一下......

EDIT: Unfortunately, the above link is broken now.编辑:不幸的是,上面的链接现在坏了。 It detailed all the steps required for comiling and running java within sublime text.它详细介绍了在 sublime text 中编译和运行 java 所需的所有步骤。 Anyways, for mac or linux systems, the below should work:无论如何,对于 mac 或 linux 系统,以下应该有效:

modify javac.sublime-build file to:将 javac.sublime-build 文件修改为:


#!/bin/sh

classesDir="/Users/$USER/Desktop/java/classes/"
codeDir="/Users/$USER/Desktop/java/code/"
[ -f "$classesDir/$1.class" ] && rm $classesDir/$1.class
for file in $1.java
do
echo "Compiling $file........"
javac -d $classesDir $codeDir/$file
done
if [ -f "$classesDir/$1.class" ]
then
echo "-----------OUTPUT-----------"
java -cp $classesDir $1
else
echo " "
fi

Here, I have made a folder named "java" on the Desktop and subfolders "classes" and "code" for maintaining the .class and .java files respectively, you can modify in your own way.在这里,我在桌面上创建了一个名为“java”的文件夹,子文件夹“classes”和“code”分别用于维护.class和.java文件,您可以按照自己的方式进行修改。

As detailed here:如此处详述:

http://sublimetext.userecho.com/topic/90531-default-java-build-system-update/ http://sublimetext.userecho.com/topic/90531-default-java-build-system-update/

Steps I took to remedy this我采取的补救措施

  1. Click Start点击开始

  2. Right click on 'Computer'右键单击“计算机”

2.5 Click Properties. 2.5 单击属性。

  1. On the left hand side select 'Advanced System Settings'在左侧选择“高级系统设置”

  2. Near the bottom click on 'Environment Variables'在底部附近点击“环境变量”

  3. Scroll down on 'System Variables' until you find 'PATH' - click edit with this selected.向下滚动“系统变量”,直到找到“路径”-单击编辑并选择此选项。

  4. Add the path to your Java bin folder.将路径添加到您的 Java bin 文件夹。 Mine ends up looking like this:我的最终看起来像这样:

    CODE: SELECT ALL代码:全选

    ;C:\\Program Files\\Java\\jdk1.7.0_03\\bin\\ ;C:\\Program Files\\Java\\jdk1.7.0_03\\bin\\

For Sublime Text 3对于崇高的文本 3
in "C:\\Program Files\\Sublime Text 3\\Packages" you get java.sublime-package copy it to another folder change its extension from .sublime-package to zip and extract it you get JavaC.sublime-build file for your Modifications as above.在“C:\\如上。
after all modifications extracted java folder again convert to .zip and change its extension .zip to .sublime-package.在所有修改后提取的java文件夹再次转换为.zip并将其扩展名.zip更改为.sublime-package。 after that copy and paste this file to C:\\Program Files\\Sublime Text 3\\Packages.之后,将此文件复制并粘贴到 C:\\Program Files\\Sublime Text 3\\Packages。
this will help you!这会帮助你!

(even you get my file from http://upfile.mobi/363820 or http://www.4shared.com/file/73SkzY-Kba/Java.html link I use to run java code i use trick of "Wesley Baugh" so you need to copy runJava.bat file to your C:\\Program Files (x86)\\Java\\jdk1.8.0\\bin directory as he says. and copy above linked file to C:\\Program Files\\Sublime Text 3\\Packages) (即使你从http://upfile.mobi/363820http://www.4shared.com/file/73SkzY-Kba/Java.html链接获取我的文件,我用来运行 Java 代码我使用“Wesley Baugh " 所以你需要按照他的说法将 runJava.bat 文件复制到 C:\\Program Files (x86)\\Java\\jdk1.8.0\\bin 目录。并将上面链接的文件复制到 C:\\Program Files\\Sublime Text 3\\Packages )

You can compile and run your code entirely in ST, and it's very quick/simple.您可以完全在 ST 中编译和运行代码,而且非常快速/简单。 There's a recent ST package called Javatar that can do this.最近有一个名为 Javatar 的 ST 包可以做到这一点。 https://javatar.readthedocs.org https://javatar.readthedocs.org

This is code to compile and run java in sublime text 3这是在 sublime text 3 中编译和运行 java 的代码

"shell_cmd": "javac -d . $file && java ${file_base_name}.${file_base_name}", "shell": true "shell_cmd": "javac -d . $file && java ${file_base_name}.${file_base_name}", "shell": true

I followed a post in this thread and got it working perfectly:我跟着这个帖子 线程,并得到它完美地工作:

Make the bat file with the following, and save it anywhere in your PATH.使用以下内容制作 bat 文件,并将其保存在 PATH 中的任何位置。 I suggest C:\\Program Files\\Java\\jdk*\\bin\\ to keep everything together.我建议 C:\\Program Files\\Java\\jdk*\\bin\\ 将所有内容放在一起。

@ECHO OFF
cd %~dp1
javac %~nx1
java %~n1

then edit C:\\Users\\your_user_name\\AppData\\Roaming\\Sublime Text 2\\Packages\\Java\\JavaC.sublime-build, the contents will be然后编辑 C:\\Users\\your_user_name\\AppData\\Roaming\\Sublime Text 2\\Packages\\Java\\JavaC.sublime-build,内容将是

{
   "cmd": ["javac", "$file"],
   "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
   "selector": "source.java"
}

replace "javac" with the name of your bat file (for instance, javacexec.bat) and save it.将“javac”替换为您的 bat 文件的名称(例如,javacexec.bat)并保存它。

By following the steps below, you will have 2 Build Systems in sublime - "JavaC" and "JavaC_Input".按照以下步骤,您将拥有 2 个 sublime 构建系统——“JavaC”和“JavaC_Input”。

"JavaC" would let you run code that doesn't require user input and display the results in sublime's terminal simulator, which is convenient and nice-looking. “JavaC”可以让你运行不需要用户输入的代码,并在 sublime 的终端模拟器中显示结果,既方便又美观。 "JavaC_Input" lets you run code that requires user input in a separate terminal window, it's able to accept user input. “JavaC_Input”允许您在单独的终端窗口中运行需要用户输入的代码,它能够接受用户输入。 You can also run non-input-requiring code in this build system, so if you don't mind the pop-up, you can just stick with this build system and don't switch.你也可以在这个构建系统中运行不需要输入的代码,所以如果你不介意弹出窗口,你可以坚持使用这个构建系统,不要切换。 You switch between build systems from Tools -> Build System.您可以从工具 -> 构建系统在构建系统之间切换。 And you compile&run code using ctrl+b.然后使用 ctrl+b 编译和运行代码。

Here are the steps to achieve this:以下是实现这一目标的步骤:

(note: Make sure you already have the basic setup of the java system: install JDK and set up correct CLASSPATH and PATH, I won't elaborate on this) (注意:确保你已经有了java系统的基本设置:安装JDK并设置正确的CLASSPATH和PATH,这里不再赘述)

"JavaC" build system setup “JavaC”构建系统设置

1, Make a bat file with the following code, and save it under C:\\Program Files\\Java\\jdk*\\bin\\ to keep everything together. 1、用下面的代码制作一个bat文件,保存在C:\\Program Files\\Java\\jdk*\\bin\\下,把所有东西放在一起。 Name the file "javacexec.bat".将文件命名为“javacexec.bat”。

@ECHO OFF
cd %~dp1
javac %~nx1
java %~n1

2, Then edit C:\\Users\\your_user_name\\AppData\\Roaming\\Sublime Text 2\\Packages\\Java\\JavaC.sublime-build (if there isn't any, create one), the contents will be 2、然后编辑C:\\Users\\your_user_name\\AppData\\Roaming\\Sublime Text 2\\Packages\\Java\\JavaC.sublime-build(如果没有,创建一个),内容为

{
   "cmd": ["javacexec.bat", "$file"],
   "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
   "selector": "source.java"
}

"JavaC_Input" build system setup “JavaC_Input”构建系统设置

1, Install Cygwin [ http://www.cygwin.com/] 1、安装Cygwin [ http://www.cygwin.com/]

2, Go to C:\\Users\\your_user_name\\AppData\\Roaming\\Sublime Text 2\\Packages\\Java\\, then create a file called "JavaC_Input.sublime-build" with the following content 2、进入C:\\Users\\your_user_name\\AppData\\Roaming\\Sublime Text 2\\Packages\\Java\\,然后创建一个名为“JavaC_Input.sublime-build”的文件,内容如下

{
"cmd": ["javacexec_input.bat", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java"
}

3, Make a bat file with the following code, and save it under C:\\Program Files\\Java\\jdk*\\bin\\ to keep everything together. 3、用下面的代码制作一个bat文件,保存在C:\\Program Files\\Java\\jdk*\\bin\\下,把所有东西放在一起。 Name the file "javacexec_input.bat".将文件命名为“javacexec_input.bat”。

@echo off
javac  -Xlint:unchecked %~n1.java 
start cmd /k java -ea %~n1
{
"shell_cmd": "javac -Xlint  \"${file}\"",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"working_dir": "${file_path}",
"selector": "source.java",

"variants": [

    { "shell_cmd":"javac -Xlint  \"${file}\" && java $file_base_name  < input.txt > output.txt",
      "name": "Run"
    }
   ]
}

save this sublime build and run the program with ctrl + shift + B with run variant.Without run variant it will just create .class file but wont run it.保存这个 sublime 构建并使用 ctrl + shift + B 运行程序并使用 run 变量。没有运行变量它只会创建 .class 文件但不会运行它。

This build will read the input from input.txt and print the output in output.txt.此构建将从 input.txt 读取输入并在 output.txt 中打印输出。

Note : both input.txt and output.txt must be present in the same working directory as your .java file.注意:input.txt 和 output.txt 必须与 .java 文件位于同一工作目录中。

Make sure u install JDK/JRE first.确保你先安装 JDK/JRE。

If you are mac user than follow this steps:如果您是 mac 用户,请按照以下步骤操作:

open terminal go to your root dictionary by typing通过键入打开终端转到您的根字典

cd ..光盘..

repeatedly.反复。 use采用

ls ls

to see if u have reach the root看看你是否已经到达根部

you will see Library folder Now follow this path Library/Java/JVM/bin Once you get into bin you can see JavaC file你会看到 Library 文件夹 现在按照这个路径 Library/Java/JVM/bin 一旦你进入 bin 你可以看到 JavaC 文件

Now u need to get the path of this folder for that just write this command现在您需要获取此文件夹的路径,只需编写此命令

pwd密码

Copy paste it to your sublime JavaC file and build java code in sublime by cmd+b.将其复制粘贴到您的 sublime JavaC 文件中,然后通过 cmd+b 在 sublime 中构建 java 代码。

Alex Yao's Answer is the simplest solution, if you just want to build and run Java program w/o taking any input from the console use the solution provided by Alex Yao . Alex Yao 的答案是最简单的解决方案,如果您只想构建和运行 Java 程序而无需从控制台获取任何输入,请使用Alex Yao提供的解决方案。 However if you would like to take input from the console then refer to the following link但是,如果您想从控制台获取输入,请参考以下链接

Java console input in Sublime Text 2? Sublime Text 2 中的 Java 控制台输入?

This is mine using sublime text 3. I needed the option to open the command prompt in a new window.这是我使用 sublime text 3 的。我需要在新窗口中打开命令提示符的选项。 Java compile is used with the -Xlint option to turn on full messages for warnings in Java. Java compile 与-Xlint选项一起使用以打开 Java 中警告的完整消息。

I have saved the file in my user package folder as Java(Build).sublime-build我已将文件保存在我的用户包文件夹中为Java(Build).sublime-build

{
     "shell_cmd": "javac -Xlint \"${file}\"",
     "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
     "working_dir": "${file_path}",
     "selector": "source.java",
     "variants":
     [
          {
               "name": "Run",
                "shell_cmd": "java \"${file_base_name}\"",
          },
          {
               "name": "Run (External CMD Window)",
               "shell_cmd": "start cmd /k java \"${file_base_name}\""
          }
     ]
}

The Build System JavaC works like a charm but fails when you want to give input from stdin in Sublime-text.构建系统 JavaC 就像一个魅力,但当你想在 Sublime-text 中从 stdin 提供输入时失败。 But you can edit the build system to make it receive input from user.但是您可以编辑构建系统以使其接收来自用户的输入。 This is the modified JavaC build I'm using on Ubuntu 18.04 LTS.这是我在 Ubuntu 18.04 LTS 上使用的修改后的 JavaC 版本。 You can edit the build System or create a new build system.您可以编辑构建系统或创建新的构建系统。

To Create a new build system.创建一个新的构建系统。

  • Go to Tools >> Build System >> New Build System .转到工具>>构建系统>>新建构建系统
  • Copy Paste the Below code and File >> Save .复制粘贴下面的代码和文件>>保存

    { {

     "shell_cmd": "javac \\"$file\\"", "file_regex": "^(...*?):([0-9]*):?([0-9]*)", "selector": "source.java", "variants": [ { "shell_cmd":"bash -c \\"javac $file\\" && gnome-terminal -- bash -c \\"java $file_base_name ;read\\"", "name": "Run" } ]

    } }

To Edit the existing Java C build file编辑现有的 Java C 构建文件

This is how I did it with these easy steps:这就是我通过这些简单的步骤做到的:

Setup a new build system:设置一个新的构建系统:

  1. Tools > Build System > New Build System工具 > 构建系统 > 新建构建系统

  2. Replace the default code with the following:将默认代码替换为以下内容:

     { "cmd": ["javac","$file_name","&&","java","$file_base_name"], "path": "C:\\\\Program Files\\\\Java\\\\jdk1.7.0_25\\\\bin\\\\", "shell": true } // locate the path of your jdk installation and replace it with 'path'
  3. Save the file by giving it a name (I named mine "Java")通过给它一个名字来保存文件(我命名我的“Java”)

Activate the build system:激活构建系统:

  1. Tools > Build System > Java (name of the file you saved it with)工具 > 构建系统 > Java(您保存它的文件的名称)
  2. Now run your program with Ctrl + B现在用 Ctrl + B 运行你的程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM