Home Download Buy Blog Forum Support

Questions about Build Systems in Tools Menu

Questions about Build Systems in Tools Menu

Postby allenm541 on Tue Feb 02, 2010 4:36 am

Hi, I've been using Sublime Text for a few months now, mostly with JavaScript, CSS, HTML and PHP.

I'm a relatively new programmer and at this point know JavaScript well, and some PHP, but that's about it. I'm beginning to learn Java and Python, and I just realized to my delight that I can test and run my Python code inside of Sublime Text by selecting the right Build System type from the Tools menu. I then also realized that I can use the Sublime Text console panel just like the Python Shell.

Anyway, my point of this post is that I'm wondering what else can Sublime Text do... under the Tools menu there is the Build System submenu... under that is listed:

Make
D
Run
Haskell
JavaC
Python
Ruby

1) My first question is what is "Make." I notice that when I write JavaScript in SublimeText that "Make" is automatically selected. What does this mean? What is "Make" and how is it intended to be used?

2) What is "Run"? How is this feature meant to be used?

3) What is JavaC? I know what Java is and I know what C is, but what is "JavaC"? Does this mean Sublime Text can be used to test and run Java code, similar to the Eclipse IDE? If so, how can I set this up? Can error messages be output to the console panel when typing Java, just like with Python?

4) Are there any other Build Systems that can be downloaded somewhere, or is this all there is? Are there some build systems available for C# or C++?

There seems to be so many gems to Sublime Text, but so little documentation for the layperson, like myself.

Thank you.
allenm541
 
Posts: 8
Joined: Tue Sep 29, 2009 12:45 am

Re: Questions about Build Systems in Tools Menu

Postby gpfsmurf on Tue Feb 02, 2010 4:53 pm

1, 4) Make is a wide-spread general purpose build system. In particular, it is used for C++ projects. Google "GNU make" and "makefile"
2) Not sure but I think "Run" just executes the file
3) JavaC is the Java Compiler, "javac.exe". It should compile your program and show any errors in the build output window.

You don't have the debugging features of Eclipse, such as breakpoints, etc.
Note that for bigger Java web applications you don't call javac directly; you usually have Apache Ant which is the Java equivalent of Make. But in that case you probably just need to run a "build.bat" file.

If you want to run the java program after it's compiled, check this thread: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=759
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Questions about Build Systems in Tools Menu

Postby allenm541 on Thu Feb 04, 2010 1:23 am

Thanks, that gives me a starting point and some things to research.

I created a "Hello World" C++ program and hit F7 in Sublime Text. "Make" was selected as the Build System. I got this error message in the console:

'make' is not recognized as an internal or external command, operable program or batch file.


I think I'm missing some core concept as to how to set this up. What do I need to do to get this to work?

I also tried compiling a simple Java program in Sublime Text with JavaC selected as the build system, but the same thing happened. I have the JDK 1.6 installed. Is there a way in which I need to tell Sublime Text where javac.exe is located on my computer? Or do I simply need to save my file in a specific location in order for it to work? (I read the link you gave me, but am still lost...)

Regarding Python... I have Python 2.6 and Python 3.1 installed on my computer; however, it doesn't appear as if Sublime Text is using either. If I enter:

Code: Select all
help()


Into the console, I get

Welcome to Python 2.5!


How can I set Sublime Text up to use Python 2.6 or 3.1?

Thanks!
allenm541
 
Posts: 8
Joined: Tue Sep 29, 2009 12:45 am

Re: Questions about Build Systems in Tools Menu

Postby gpfsmurf on Thu Feb 04, 2010 3:12 pm

Sublime needs to find the tools you're using (make.exe, javac.exe, etc); add them to your %PATH% environment variable.

For 'make' to work, you also need to create a makefile. It's overkill for a hello world program, but it's a good exercise I guess. Google it or look for C++/make tutorials.

As for Python, Sublime comes with its own version of python (2.5.2 atm), which is also what you have in the console. It's also what's used by the plugins.

If you run your own .py files, it'll use your default python installation, not Sublime's. Which version is used depends on the %PATH% variable as well.
gpfsmurf
 
Posts: 211
Joined: Mon Jun 23, 2008 6:31 pm

Re: Questions about Build Systems in Tools Menu

Postby allenm541 on Fri Feb 05, 2010 3:11 am

Hmm... it sounds like it will be more difficult than I anticipated. I have no idea where to put the %PATH% variable you're referring to or how to code it.
For now, I think I'll have to use other editors while I learn C++ and Java. I love Sublime Text, but if there's no easy way to run and test... In the mean time I'll keep using it to learn Python with.

Thanks for your help gpfsmurf. I'll do some study on how to create a makefile... ;)
allenm541
 
Posts: 8
Joined: Tue Sep 29, 2009 12:45 am

Re: Questions about Build Systems in Tools Menu

Postby allenm541 on Sat Feb 06, 2010 4:44 am

Yeah, I got it to work! At least the Java part of it....

I manged to find this doc page through a Google search: http://www.sublimetext.com/docs/build

That was very helpful. First I saved a Hello.java file to C:/test

Code: Select all
class Hello {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Display the string.
    }
}


I realize now what you meant by setting my %PATH% variable. I needed to point commands received to that directory location to the javac.exe app by setting this in the command prompt:

Code: Select all
C:\test> set PATH=%PATH%;C:\jdk1.6.0_16\bin


Then in Sublime Text I selected Preferences -> Browse Packages. Then I opened the Java folder and found the file JavaC.sublime-build
This is what it showed me on the first line:

Code: Select all
build javac.exe


I then changed it to:

Code: Select all
build javac.exe "$File"


This compiled the file, but didn't do anything else, so I wasn't getting any response in the console. Each time I hit F7 in Sublime Text it actually needed to build twice: once to compile the .java file to a .class file, and the second time to run the .class file.

So I added this line underneath of the other, which mimics the way a Java class file is run in the command prompt:

Code: Select all
build java.exe "$BaseName"


And now it works. :)

Whew... simple enough once you know what you're doing. Still working on getting a C++ file to compile and run....
allenm541
 
Posts: 8
Joined: Tue Sep 29, 2009 12:45 am

Re: Questions about Build Systems in Tools Menu

Postby knitatoms on Sat Feb 06, 2010 9:24 am

Newbie here learning Python....

Is it possible to test out my Python programs in the console without having Python installed? If I choose Python as the build system and then hit F7 with a python file open I just get "python.exe is note recognized as in internal / external command."

I can only find a Python.dll with the Sublime install.

I know it's easy to install Python but I like the idea of using Sublime for quick testing and learning on my Netbook or other PCs without having to install and additional instance of Python.
knitatoms
 
Posts: 22
Joined: Sat Feb 06, 2010 9:01 am

Re: Questions about Build Systems in Tools Menu

Postby allenm541 on Mon Feb 08, 2010 4:07 am

Yeah, I think you need Python installed, I don't think Sublime Text installs it for you... I could be wrong. But either way, you'd need some version of it installed one way or another if you plan to use it.

Well, I'm a newbie too, but what I've been doing is making sure that I save my Python file to the Python installation folder in the root directory of the drive.
So, for example, install Python 2.6 and it places a folder called Python26 in the root of your C drive. Then save your .py files in Sublime Text to that directory and when you run the file by pressing F7 it uses that Python installation.

Anyone else have any insight as to why this works? Or how to set it up so that files could be saved anywhere else on the system and still know how to use Python?
Last edited by allenm541 on Mon Feb 08, 2010 4:17 am, edited 2 times in total.
allenm541
 
Posts: 8
Joined: Tue Sep 29, 2009 12:45 am

Re: Questions about Build Systems in Tools Menu

Postby allenm541 on Mon Feb 08, 2010 4:11 am

Actually, I guess you could try this too:

Preferences -> Browse Packages. Find the Python.sublime-build file and open it.

Then change the first line to this and save the file:

Code: Select all
build "C:/Python26/python.exe" "$File"


Or if you're using Python 3.1:

Code: Select all
build "C:/Python31/python.exe" "$File"
allenm541
 
Posts: 8
Joined: Tue Sep 29, 2009 12:45 am

Re: Questions about Build Systems in Tools Menu

Postby knitatoms on Mon Feb 08, 2010 10:50 am

Thanks for the replies allenm541 - yes that approach works. You can also just add the location of your preferred python.exe to your windows Path environment variable and it will work fine.

I'm still wondering if it's possible to run python files without installing python and just using the python files that come with sublime (python dll and also a zipped python 2.5 distribution) - but no big deal if this isn't possible.
knitatoms
 
Posts: 22
Joined: Sat Feb 06, 2010 9:01 am

Next

Return to General Discussion

Who is online

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