Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Basics Getting Started with Java Introduction to Your Tools

How do I Follow along in Sublime Text 2

What do I need to do in order to set up Sublime text 2 so I can follow along with the classes. So far, when I type "javac Introductions.java", "I get back a "SyntaxError: invalid syntax".

This is my first time working with Java and I am also fairly new to using sublime.

In order to help you diagnose your syntax error, we'd need to see the code that you are trying to run or at least more of the error message.

import java.io.Console;

public class Introductions {

    public static void main(String[] args) {
        Console console = System.console();
        // Welcome to the Introductions program!  Your code goes below here
        console.print("Hello, my name is Craig");
  }
}

Above is the code that I am attempting to compile. Works great in workspaces when I input "javac Introductions.java", not so much when I attempt the same thing in Sublime. I get the following.

javac Introductions.java

file "string", line 1

javac Introductions.java

SyntaxError: invalid syntax

1 Answer

I see at least one issue with the code as you have it. You are trying to call console.print which isn't a valid function name. The actual function is named printf so if you change

console.print("Hello, my name is Craig");

to

console.printf("Hello, my name is Craig");

your program should compile.