sublime3 java linux,如何设置Sublime text 3在linux上运行和编译java?

一位初学者在尝试使用Sublime Text编译和运行Java代码时遇到困难,之前使用过NetBeans,但更倾向于简洁的IDE。在Ubuntu 14.10上设置Sublime Text时遇到问题。最终找到解决方案是在Ubuntu 16.04 LTS上测试有效的Sublime Text 3配置:创建.sublime-build文件,包含特定的shell_cmd来编译和运行Java文件。这样可以同时编译和运行基于文件名的类,并显示'HelloWorld'的输出结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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..

QWPQ3.png

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

xhcGD.png

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!

解决方案

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",

}

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"

cl9Tv.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值