(Sublime Text 3) bash: javac: command not found

huangapple go评论70阅读模式
英文:

(Sublime Text 3) bash: javac: command not found

问题

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

I'm trying to get a working build system for Java on Sublime Text 3, but whenever I try to run anything, i just get bash: javac: command not found.

The strangest thing about this is that I can run the javac command from a terminal, as I have added the line

export JAVA_HOME=/usr/lib/jvm/java-14-openjdk && export PATH=$JAVA_HOME/bin:$PATH

to the .bashrc file in my home directory.

So I have no idea why I can run Java files using javac and java from the terminal, however Sublime Text cannot.

Here is what I have for my build system:

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

I am using Manjaro 20.

答案1

得分: 1

我看到你正在使用Manjaro,这是Arch的派生版;与其设置JAVA_HOME变量,你应该使用archlinux-java来设置默认的JDK版本。
archlinux-javajava-runtime-common包的一部分。


当出现问题时,Sublime会打印出你当前的路径变量(示例)。确保路径设置正确。

我在我的Arch机器上尝试了你的构建系统,它正常工作。我还尝试了设置JAVA_HOME变量,它仍然可以工作。

使用Sublime Text 3 Build 3211

英文:

I see that you are using Manjaro, which is Arch derivative; instead of setting the JAVA_HOME variable, you should use archlinux-java to set the default JDK version.
archlinux-java is part of java-runtime-common package.


When something is wrong, Sublime will print your current path variable (example). Make sure the paths are set correctly.

I tried your build system on my Arch machine, and it is working correctly, I also tried setting the JAVA_HOME variable, and it is still working.

Using Sublime Text 3 Build 3211

答案2

得分: 0

对于将来遇到相同问题的用户,我通过在构建系统中添加以下内容来解决了这个问题:

"path": "你的/目录/在这里"

在我将这一行添加到 .bashrc 文件中的整个操作最终被证明是完全不必要的,因为这样修复了该问题。

英文:

For future users with the same issue, I solved it by specifying the path variable in my build system by adding:

"path":"your/directory/here"

The whole thing where I added the line to .bashrc turned out to be completely unnecessary, as this fixed it.

huangapple
  • 本文由 发表于 2020年8月21日 19:55:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/63522477.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定