Sublime Text won't output Java println statements in main method

761 views Asked by At

my Sublime Text javac build settings don't work for outputs like System.out.println statements in the main method.

I am using this sublime-build (javac):

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

    "variants": [

        { 
            "name": "Run",
            "cmd": ["java", "$file_name"],
            "shell": true,
            "env": {"CLASSPATH": "/path/to/jar/files:/path/to/more/jars"}
        }
    ]

}

Changing "cmd" to

"cmd": ["javac \"$file_name\" && java \"$file_base_name\""]

won't work either. But it compiles correctly and has a correct output on my bash command line.

Any thoughts?

Thanks in advance!

1

There are 1 answers

0
christophe On BEST ANSWER

Nevermind, I got it:

That's the magic line missing:

"cmd": ["sh", "-c", "javac $file_base_name.java && java $file_base_name"],