1

Recently I installed Windows 8 on my notebook, but I'm not longer able to build anything using Sublime Text 2. Neither Java nor in other languages​​.

I've already configured the path variables, I'm able to compile java manually via command prompt (jdk1.7.0_51), but when I try to build on Sublime, just a "Building" message appears at the bottom and nothing happens.

I used the same settings also from two other computers with Windows 8 that are running and it did not work.

I try to use the standard sublime-build option and this code:

{
    "cmd": ["javac", "$file_name","&&","java", "$file_base_name"],
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "path": "C:\\Program Files\\Java\\jdk1.7.0_51\\bin\\",
    "selector": "source.java",
    "shell": true
}

I tried these links but also didn't work: Compiling and Running Java Code in Sublime Text 2 and Sublime Text don't build anything

For instance, I try to compile C++ and C and nothing happens. Just the "Building" message but no erros. Any suggestions?

Community
  • 1
  • 1

1 Answers1

0

Try changing your build system to the following:

{
    "cmd": ["start", "cmd", "/k", "javac", "$file"],
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.java",
    "path": "C:\\Program Files\\Java\\jdk1.7.0_51\\bin",
    "working_dir": "$file_dir",
    "shell": true,

    "variants":
    [
        {
            "name": "Run",
            "cmd": ["start", "cmd", "/k", "java", "$file_base_name"],
            "working_dir": "$file_dir",
            "shell": true
        }
    ]
}

Save this file as Packages/User/Java_cmd.sublime-build where Packages is the directory opened by going to Preferences -> Browse Packages.... Then, make sure you select Java_cmd from the Tools -> Build System menu.

This actually sets up two build systems - the first one, bound to CtrlB, compiles your program within Sublime. The "Run" variant is bound to CtrlShiftB. It opens a cmd.exe window, runs your compiled class, and then returns to the command prompt, allowing you to examine the output of your program. If you don't want the command prompt window to remain open after running, just change the "/k" flag to "/c".

Good luck!

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • It didn't work. The build results window shows nothing. I don't get any message or error. I tried to compile the code using build system from other languages, but I got no errors. – Marcus Vinicius Vasconcelos Feb 21 '14 at 16:54
  • @MarcusViniciusVasconcelos try the edit I just posted. My initial build system had a few misplaced commas. I also added the `"start", "cmd", "/k",` commands to the initial `javac` command, so everything should happen at the command prompt. Sublime will probably just say `"Building..."` in the build window, and you won't get the `Finished...` message until you close the command prompt. Please let me know how it works... – MattDMo Feb 21 '14 at 20:32
  • Still don't work. Like I say, I tried others build system like C++ to compile a blank file. On others computers building an blank file lead to this message: [Decode error - output not utf-8] [cmd: [u'g++', u'', u'-o', u'/']] [dir: C:\\Sublime Text 2.0.1] [path: XXXXX] [Finished] But this is not happens in that computer. It just say Building and nothing else. BTW, thanks for the help! – Marcus Vinicius Vasconcelos Feb 24 '14 at 15:28