Sublime Forum

How to only compiling java and not running it in ST3 Windows

#1

I currently use windows and Sublime to do my java programming in college and I hate using the command line to compile. Whenever I use ctrl+B I get this:

[dir: C:\Users\jonat\Desktop\Java Projects]
[path: C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Razer Chroma SDK\bin;C:\Program Files\Razer Chroma SDK\bin;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 (x86)\Intel\Intel® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Intel\Intel® Management Engine Components\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\jonat\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Common Files\Seagate\SnapAPI;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\QuickTime\QTSystem;C:\Users\jonat\AppData\Local\Microsoft\WindowsApps;;C:\Program Files (x86)\Common Files\Acronis\TibMounter64]

I don’t understand what to do. I have seen plenty of forum posts about how to compile and run java but 95% of the time I’m inputting into the program. When my mac partition was working I didn’t have o do anything to compile in ST3.

Help would be greatly appreciated!

0 Likes

#2

Until now, I do not found any concrete solution to build Java programs/projects on Sublime Text. When I need to, I open Eclipse IDE and build/run the code.

Building java by command line is a nightmare. I would suggest using maven or ant build system then call these scripts from Sublime Text, by creating a .sublime-build.

  1. http://ant.apache.org/
  2. https://maven.apache.org/what-is-maven.html
  3. https://www.sublimetext.com/docs/3/build_systems.html
  4. http://docs.sublimetext.info/en/latest/reference/build_systems.html

For example, to build a simple java program only with one file, you can use this build system:

{
	"shell_cmd": "javac \"$file\"",
	"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
	"selector": "source.java"
}

To build and run, I am not sure about the syntax, you will have to study a little. Perhaps it is somethings like this:

	"shell_cmd": "javac \"$file\" && java \"$file_base_name\"",
  1. http://docs.sublimetext.info/en/latest/reference/build_systems/configuration.html#build-system-variables
0 Likes

#3

Thanks addons_zz, I’ll take a look at those IDEs

0 Likes

#4

Hi, I run java code inside sublime without problems. According to your path, you don’t have the java environment variable added to the path or isn’t configured correctly. Something like C:\Program Files (x86)\Java\jdk1.8.0_91\bin should appear.

There is a sublime package for Java development too: https://packagecontrol.io/packages/Javatar

1 Like