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
Ben Os
20,008 PointsWhere to display console text in Java?
I started the "Java basics" course and took the first series of lessons.
I went to my Ubuntu, installed javac, and created a file named Introductions.java, there I wrote:
import java.io.*;
public class Introductions {
public static void main( String[] args ) {
Console console = System.console();
console.printf("hello");
String userName = console.readLine("Enter your user name: ");
console.printf("First name: %s", userName);
}
}
I than compiled it via javac Introductions.java and got the file: Introductions.class in return.
My question is this:
Given the source code prints the string "hello", and given the Introductions.class contains machine coded when opened with a text editor, where should I see the printed string "hello" at?
I executed in Bash, in the same dir, java Introductions.class, and didn't get the string printed, hence I ask this.
1 Answer
Craig Dennis
Treehouse TeacherTo run the program, you type java Introductions without the .class extension.
That help?
Ben Os
20,008 PointsBen Os
20,008 PointsHi Craig! Yest it did! Thx! ^__^