Sublime Forum

ST3 Java Compile & Run

#1

Hi to all,
I recently have installed Sublime text 3 and i use it to write on java for my uni.I know that with ST3 you can compile ur program but cannot run it,also i saw many posts
with same subject but i couldnt make it work.Can anyone explain me how to make ST3 to compile and run my program?.

Thanks for your time :wink:

0 Likes

#2

C:\Users_USER_NAME_\AppData\Roaming\Sublime Text 3\Packages\

Go to that directory. Make a folder called β€œJava” open the folder. then make a new file called β€œJavaC.sublime-build”

paste this

 {
	"cmd": ["runJava.bat", "$file"],
	"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
	"selector": "source.java"
}

Now make another file call it runJava.bat

and paste in that file

@ECHO OFF cd %~dp1 ECHO Compiling %~nx1....... IF EXIST %~n1.class ( DEL %~n1.class ) javac %~nx1 IF EXIST %~n1.class ( ECHO ‐‐‐‐‐‐‐‐‐‐‐OUTPUT‐‐‐‐‐‐‐‐‐‐‐ java %~n1 )

and call it β€œrunJava.bat”

Then where ever you java jdk bin folder is e.g C:\Program Files\Java\jdk1.8.0_102\bin

put runJava.bat in there

works fine with me

0 Likes