Home Download Buy Blog Forum Support

First time with sublime. How to run code on java

First time with sublime. How to run code on java

Postby Python93 on Sat Feb 16, 2013 4:28 am

Ok so I usually use eclipse for compiling in java but I don't know how to create the equivalent of a project, class and then how to compile it.
What am I supposed to do? The only thing I have done is installed it on Windows. That's it. I clicked on file > New File and typed in my java code and pressed f7 and it says:
The system cannot find the file specified
[cmd: [u'javac', u'']]
[dir: C:\Windows\system32]
[path: C:\Program Files (x86)\HP SimplePass 2011\x64;C:\Program Files (x86)\HP SimplePass 2011\;;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\12.0\DLLShared\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\]
Posts: 1
Joined: Sat Feb 16, 2013 4:23 am

Re: First time with sublime. How to run code on java

Postby skuroda on Sun Feb 17, 2013 2:35 am

I don't see the Java SDK in your path. I don't recall how Eclipse installs java. You may need to install the Java SDK on your machine, then ensure the executable are on your PATH
Posts: 692
Joined: Fri Oct 05, 2012 8:11 am

Re: First time with sublime. How to run code on java

Postby johnwin on Thu Feb 21, 2013 8:07 am

Your path might not appear to work if you haven't referenced the correct folder - that set by step I posted way back only applied for that version of the JDK.

If you aren't seeing any menu when you right click on 'Computer' try this instead.

For JDK version jdk1.7.0_07 Just update this with location of your JDK when a new version is released.

Type "Path" (without the quotes) into the search area
You should see "Edit environment variables for your account" <--- click this
A window should appear titled "Environment Variables"
Click TEMP on the top area
Scroll a little bit on the bottom second area until you find Path
Select Path and click Edit...
Paste this in at the very end of bottom text area
;C:\Program Files\Java\jdk1.7.0_07\bin

Make sure to OK out of both windows
Restart Sublime text if needed

That's all there is to it.

So to actually get compiling and running your java programs after completing the above, you will need to do the following. Just create a simple java class so you are on the same page as me

Building your Java class

Open a new SublimeText2 document and paste the following

class hello {
public static void main(String[] args) {
System.out.println("Hello World!");

Then save that file to your Desktop - call it

you should have something like this

Now press Ctrl+b on your keyboard to build your java class which should produce this!

Finally! - Running your Java program!

You need to open a command prompt window, so go ahead and do that.
Then navigate to the folder (in this case our desktop) where your java class is located
navigating using the command prompt is easy - just use

cd <-- this stands for change directory
dir <-- this will list everything in the current directory if you get stuck!
in my case it looks like this

Cool, looks like we are in the right place.
Finally type the following

java hello

I hope this helps anyone who stumbles across this!
Posts: 1
Joined: Mon Feb 04, 2013 9:30 am

Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 20 guests