Reputation: 6552
OS:
Distributor ID: Ubuntu
Description: Ubuntu 12.04.2 LTS
Release: 12.04
Codename: precise
Sublime Text 2 is 2.0.1 for Linux 32-bit
There is JAVA_HOME set up in my environment and JAVA_HOME/bin included in $PATH
$ cat /etc/bash.bashrc
export ENV_HOME="/media/work/Environment"
export JAVA_HOME="$ENV_HOME/Java/jdk1.7.0_04"
export PATH=$PATH:$JAVA_HOME/bin
Isn't Java program compilation and running supported out-of-the-box without any manual configurations or modifications?
When I am trying to build my simple program Test.java
class Test {
public static void main(String[] args) {
System.out.println("Jignesh Gohel");
}
}
I am getting the following error in Sublime Text console:
[Errno 2] No such file or directory
[cmd: [u'javac', u'/media/work/Java/Test.java']]
[dir: /media/work/Java]
[path: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games]
[Finished]
Following is the JavaC.sublime-build content:
{
"cmd": ["javac", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java"
}
I found following links mentioning solution to my above query:
https://gist.github.com/jfcalvo/3789664 http://www.compilr.org/compile-and-run-java-programs/1251/ Can't compile Java with Sublime Text 2, Ubuntu 12.04 64
but they still require me to make modifications manually.
Thanks,
Jignesh
Upvotes: 1
Views: 2559
Reputation: 4643
I am not sure if you would like to give it a try again for sublime text.
It is really an editor which is flexible for the programmers.
After digging into the problem that we both have,
you can revise your JavaC.sublime-build as the following.
{
"cmd": ["javac \"$file_name\" && java \"$file_base_name\""],
"shell": true,
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java"
}
By doing this, pressing F7 should come up with something you expect.
Upvotes: 1