Sublime Forum

Using Sublime Text 3 as a Java IDE

#1

Hi, I’m currently a college student looking to major in computer science. I took a basic programming course on Java and would like to code Java on Sublime Text because it is very lightweight, portable, and I want to learn how to use it as many programmers found it as an essential tool for their work.

I googled and found Javatar to be a relevant plugin for what I’m doing but am having trouble understanding the need for a source folder and packages. Since I’m just learning, all I’m dealing with is a .java/.class file in a folder or maybe several files in a folder (inheritance). On Javatar, I can’t just simply create a .java file if I want to just create one class and run it–I get errors like “unknown package/class location.” How do I fix this and what does a source folder have to do with this? Step-by-step process would be ideal. It seems like such a hassle to do all these things when I can just save a document as a .java file and run it on command prompt without creating a package/project/source folder, etc., though I know that professional projects will use an established structure.

I read Javatar’s getting started guide, but it only tells me what to do and not why I have to do it. It also seems like so much work you have to do before you can even code.

0 Likes

#2

But why? IntelliJ is much better than Sublime for Java coding, because it has perfect refactoring and code navigation, and nowadays supports everything Sublime does (including multiple cursors)

You can still use Sublime on the side for various stuff, but for Java development? That’s just crazy talk.

0 Likes

#3

There’s no official portable version for Intellij IDEA and I would have to paid for their version which lets me code in JavaScript and Python (which I assume programmers would want to know). There’s no official portable version for Netbeans or Eclipse either (the portableapps.com’s version is not official and I had a huge headache trying to get it to run as flawlessly as the desktop counterpart on a flash drive).

Like I said, I really want to use Sublime Text to its fullest potential since I use it as a replacement to Notepad++ for note-taking purposes. Having a full-featured IDE on a flash drive will be slow and right now I’m only dealing with basic programs/code.

Anyway, I think my problem I’m having with Javatar is its failure to detect JDK/java/javac because I tried using Command Prompt to compile and run the code and it couldn’t detect javac/java. Seems like I have to change the environmental variables, but I don’t know which ones and to which paths (googling gave me a bunch of different answers, such as JDK_HOME, PATH, etc.).

0 Likes

#4

[quote=“mindstormer”]There’s no official portable version for Intellij IDEA and I would have to paid for their version which lets me code in JavaScript and Python (which I assume programmers would want to know).
[/quote]

So use IntelliJ for Java and ST3 for the rest. It’s a popular combination. I agree with Nimzow that not using an IDE for Java is a pretty bad idea (no pun)

Who cares - the unoffical approach works just fine.

0 Likes

#5

[quote=“mindstormer”]There’s no official portable version for Intellij IDEA and I would have to paid for their version which lets me code in JavaScript and Python (which I assume programmers would want to know).
[/quote]

So use IntelliJ for Java and ST3 for the rest. It’s a popular combination. I agree with Nimzow that not using an IDE for Java is a pretty bad idea (no pun)

Who cares - the unoffical approach works just fine.

0 Likes

#6

I need a portable version unless I want to manually install Netbeans every time I use a public computer (which is 2-3 times a day). I already gave reasons why I prefer to use Sumblime Text for compiling and running basic Java code and I am asking how I can do something that can be done by a software in the said software’s forums. Also, I literally said I had problems with the unofficial portable version of Netbeans, which seem to behave differently than the official version. I realize that using an IDE is preferred and inevitable in a professional environment but I am not at the point yet and Sublime Text is useful even for those that are employed when they want something that is lightweight, convenient, efficient, and portable.

0 Likes

#7

I think the best you’re going to get right now would maybe be lint and code completion. (Which honestly is more than fine for small things.) You’re not going to get debugging, refactoring, auto importing, etc. because most of these things can’t be done statically and require you to run the actual code you’re developing along side editing their source files (hence IDE). At the end of the day ST is not an IDE. And you’re probably going to be frustrated if you try to use it like one.

0 Likes

#8

Since no one has answered your question, I will.

  1. To use Javatar, you must first set the source folder. This allows Javatar’s compiler to know where everything is. I recommend creating a folder on your drive called src to keep everything nice and organized.

  2. Next, press Ctrl+Alt+k, Ctrl+Alt+k (twice in succession) to open Javatar’s main menu. Select Javatar Settings and set your JDK. Now, I’ve had quite a bit of trouble doing this from a flash drive because I think Java looks in the Environment Variables, which often cannot be changed on public computers. Maybe you will have a different experience.

  3. In any case, after that, you must set the source folder. Go into the menu and select Project Settings --> Set Source Folder and select your new folder.

  4. Next you must create a new class. Go back to the Javatar menu and select Create --> Class. Simply type the name of the class you would like to make and hit enter. This will create a class in the default package, which is discouraged. If you have several files that relate to each other, but not to other files, create a package for them. It will keep your project folder organized and make Javatar happy.

  5. To put files in a package, create a folder in your source folder and name it the name of your package. Put all the files you want in the package in that folder and add the following on the first line:

package packageName; //packageName must match folder name (case sensitive)

NOTE: To do steps 4 and 5 at the same time, type the name of the package followed by a dot and the name of the class when creating a new class. Javatar will place the file in the correct package folder or create it if necessary.
NOTE: If you have sub-packages, they are defined like a class in a package, ie:

package package1.package2;
  1. To run your code, open the Javatar menu and select Builds --> Package/Working/Project (whatever you want), then select Run Main Class to run the code. Note that as of now, Javatar does not support running applets, but they will compile.

==========================================================================================================

UPDATE (2/3/15)
I have been playing around with trying to get a portable version of the Java JDK on my flashdrive so Sublime and Eclipse and whatnot will work. While I haven’t quite gotten it working, Javatar has a setting for which paths to check for JDKs. By adding the path to the JDK on your flashdrive, Javatar will see it and be able to compile and run java code.

Hope that helps.

2 Likes

#9

Don’t know why intellijI IDEA lags. its not smooth. and Im beginner so I can practice on sublime

0 Likes