Sublime Forum

ST3 for java projects

#1

Hey all,

I’m starting a Java class, and the instructor is wanting us to use jGrasp, a program that I find barbaric and annoying to use.

Instead, I have been using eclipse, but for what this class is like, it feels like overkill. I’ve been using ST3 with Unity3D (for my own projects) and I love it, especially how clean and simple it is, as well as lightweight.

My question is, how can I compile and run java programs within ST3? I’ve found some tutorials but they are all for ST2 and don’t seem to work.

0 Likes

#2

Not sure how much you know of Java yet, so let’s cover the basics; Keep in mind that ST3 itself cannot compile Java class files, it is simply a fancy text editor. However, it can be configured to call an external build tool, much the same as how Eclipse, NetBeans or Idea do. This is handled through the built-in Build System support.

If you have a look in the Tools > Build System menu, you’ll see there’s already an option configured for Apache Ant. This quite simply calls the “ant” command tool in the root of your current project folder (root of the directory tree shown in the left). This assumes your “build.xml” is in the root and that the default target is your build command, so it’s not the most flexible option ever. Beyond this, if your projects use a different build system such as Maven or Gradle, then you’ll need a new build system target for Sublime to run the “mvn” or “gradle” commands.

Alternatively, you could install Package Control and use an extra package such as Build Ant Target for some finer control.

If you don’t manage to get this working, post a few more details here and I’m sure we should be able to create a ST3 build system file that will do what you need. :smile:

[edit] Just a quick note regarding Build Ant Target, only just discovered this now, because a couple of the Java projects I have here were created in NetBeans. So, keep in mind this ST plugin won’t automatically know about all the extra config that an IDE like NetBeans, Eclipse, Idea, etc… configures when they start up. It quite literally runs a target in the current file with anything that particular script file asks for.

You might want to check with your class instructor and see what he/she says… If the build script are going to be hand crafted anyway, then you’re styling. But if they’re going to be pre-generated, you might run into a few issues.

0 Likes

#3

You may consider a couple other packages that could be useful for developing Java in sublime. https://sublime.wbond.net/packages/Javatar has a variety of useful utilities. I still find frequent uses for eclipse as well but another package that is very helpful for autocomplete in sublime with java is https://sublime.wbond.net/packages/Subclim if you run it alongside eclipse or atleast the eclim service.

0 Likes