如何设置Sublime text 3在linux上运行和编译java? [英] How to set up Sublime text 3 to run and compile java on linux?

查看:208
本文介绍了如何设置Sublime text 3在linux上运行和编译java?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我决定学习Java并尝试一下。我有python的短期和业余经验,因此我不是一种编程专家。经过多天努力弄清楚如何设置Sublime Text来运行和编译Java,我决定寻求任何帮助。
我已经安装了JDK而我使用的是Netbeans,但我更喜欢简约的IDE。
我在下面创建了一个.sublime-build文件。

Recently I've decided to learn Java and give it a try. I have a short and amateur experience with python, therefore I'm not a kind of programming expert. After many days trying to figure out how to set up Sublime Text to run and compile Java, I've decided to come for any help. I've already installed JDK and I was using Netbeans, but I prefer a minimalistic IDE. I created a .sublime-build file like this below..

然而,当我尝试构建代码时,它会返回下面的错误..

However when I try to build the code, it returns me that error below..

所以,我可能做错了什么,但我无法弄明白它是什么是。我正在使用Ubuntu 14.10,这就是我找不到很多答案的原因,所以如果有人能帮助我,我真的很感激!

So, probably I've done something wrong, but I can't really figure out what it is. I'm using Ubuntu 14.10 and that's the reason I cannot find many answers out there, so I'd really appreciate if anyone could help me out!

推荐答案

使用Sublime Text3在 Ubuntu 16.04 LTS上测试。
制作您自己的 sublime-build 系统,并输入以下代码:

Tested on Ubuntu 16.04 LTS with Sublime Text3. Make your own sublime-build system, and enter this code:

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

这将让你先编译文件并运行该类基于文件名一起使用。在此之后,您将看到字符串Hello World的结果

This will let you first compile the file AND run the class based on the file name together. After this, you will see the result of string "Hello World"

这篇关于如何设置Sublime text 3在linux上运行和编译java?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆