Let's make a note... -StartingFromNothing-

Friday, June 7, 2013

Write and run java program using Sublime Text 2

Sublime Text 2 is one of my Favorite text editor for coding after Geany. This is an awesome and light weight editor. What I loved to share is how to setting ST2 then you can use it to compile and run java programs directly.

Follow these steps below to prove it :)

  1. Firstly, make sure that you already have jdk installed. Or you can download here.
  2. After installing then set the PATH variable on Environment Variables (Right click on My Computer > Properties > Advanced system settings > Environment Variables).
  3. Then go to System variables > Path > add jdk bin directory path. For example: C:\Program Files\Java\jdk1.7.0_17\bin.
  4. Create a bash shell script file runJava.bat :
  5. Next step is setting this bash shell script in the build system of ST2. Open ST2 > Preferences > Browse Packages > go to Java Folder > Open JavaC.sublime-build and replace this line "cmd": ["javac", "$file"], with this "cmd": ["runJava.bat", "$file"], then save.
  6. Done. Then open your java program using ST2 or write a simple program and click Tools > Build or simplify you can press Ctrl+B.

No comments:

Post a Comment