Sublime Forum

Build system for portable java

#1

I’m trying to use sublime text portable and a portable JDK on a computer that I cannot get admin rights on. I’m new to build systems, and the documentation I have found was not helpful. Does anyone know how to accomplish this? Here is the build system I am using:

{
“cmd”: [“javac”, “${file_name}”, “&&”, “java”, “${file_base_name}”],
“file_regex”: “^[ ]file “(…?)”, line ([0-9]*)”,
“path”: [“C:\Users\WCBDC\mark\java\jre1.8.0_351”],
“selector”: “source.java”,
“shell”: true
}

and the output looks like this:

str expected, not list
[cmd: [‘javac’, ‘HelloWorld’, ‘&&’, ‘java’, ‘HelloWorld’]]
[dir: C:\Users\WCBDC\mark\Java]
[path: C:\ProgramData\Oracle\Java\javapath;c:\Program Files (x86)\Intel\iCLS Client;c:\Program Files\Intel\iCLS Client;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x64;C:\WINDOWS\System32\OpenSSH;C:\Users\WCBDC\AppData\Local\Microsoft\WindowsApps;]
[Finished]

When I build a file, I can’t find a .class file with the same name anywhere. I noticed that sublime might be trying to use the regular java path to find the compiler, how do I change this to the directory I specified in the “path” command?

0 Likes

#2
  1. I’d recommend shell_cmd rather than cmd with shell: true as the latter ones are deprecated.
  2. A working directory which is most likely used as output directory by javac can be specified using working_directory key.
  3. Path separators need to be escaped \\ in JSON.
  4. path key must be a string, not a list.
  5. path needs to point to java’s “bin” directory
  6. JAVA_HOME env may be required
  7. file_regex should contain valid patterns (...?) is not valid. It’s a placeholder from the documentation site.
{
    "shell_cmd": "javac \"$file\" && java $file_base_name",
    "file_regex": "^[ ]file \"(.+)\", line ([0-9]*)",

    "working_dir": "${file_path:${folder}}",

    "env": {
        "JAVA_HOME": "C:\\Users\\WCBDC\\mark\\java\\jre1.8.0_351",
    },
    "path": "C:\\Users\\WCBDC\\mark\\java\\jre1.8.0_351\\bin"
}
1 Like