9 Replies - 437 Views - Last Post: 03 September 2012 - 02:41 AM Rate Topic: -----

#1 ElectricTuna.exe  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 02-September 12

Hello World!

Posted 02 September 2012 - 07:31 PM

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


Looks pretty simple, doesn't it? I'll concede that it is. "Well, then what's the problem?" you ask? My JDK doesn't want to compile for some reason. I keep getting an error, and I'm not sure why.

Welcome.java:3: cannot find symbol
symbol : method printIn(java.lang.String)
location : class java.io.PrintStream
System.out.printIn("Hello World");
(the arrow is pointing at the dot after 'out')
1 error

I'm using JDK 1.6.0_27. Any help?

Is This A Good Question/Topic? 0
  • +

Replies To: Hello World!

#2 Sheph  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 432
  • View blog
  • Posts: 1,020
  • Joined: 12-October 11

Re: Hello World!

Posted 02 September 2012 - 07:42 PM

Ooo do I still have the solution to this in my signature?

It's printLn() (lowercase L) - not printIn.

Anyways, welcome to DIC! :)

This post has been edited by Sheph: 02 September 2012 - 07:43 PM

Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10596
  • View blog
  • Posts: 39,259
  • Joined: 27-December 08

Re: Hello World!

Posted 02 September 2012 - 07:44 PM

It's not printIn, it's println. The ln is short for line.
Was This Post Helpful? 1
  • +
  • -

#4 ElectricTuna.exe  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 02-September 12

Re: Hello World!

Posted 02 September 2012 - 07:50 PM

Thanks! It's no longer giving me an error. Now what? I assume it's compiled, but nothing happens...Isn't there supposed to be some sort of output somewhere? I placed the "Welcome.java" into a folder titled "Welcome". Then, I hold down the shift button, right click on the folder, and choose "open command prompt here". So now I type "javac Welcome.java".

Nothing happens.
Was This Post Helpful? 0
  • +
  • -

#5 Sheph  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 432
  • View blog
  • Posts: 1,020
  • Joined: 12-October 11

Re: Hello World!

Posted 02 September 2012 - 07:57 PM

Are you following some sort of tutorial? It should tell you the basics of compiling and running your code from the command line. At least the Oracle tutorial does:

http://docs.oracle.c...java/index.html
Was This Post Helpful? 0
  • +
  • -

#6 ElectricTuna.exe  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 23
  • Joined: 02-September 12

Re: Hello World!

Posted 02 September 2012 - 08:01 PM

Hey,thanks again. No, no tutorial. I'm actually enrolled in Java I at my local community college. So far, neither the book that I've ordered or my instructor seem to be very helpful. That's why I joined here :P
Was This Post Helpful? 0
  • +
  • -

#7 Mina-no-Hime  Icon User is offline

  • D.I.C Head

Reputation: 98
  • View blog
  • Posts: 176
  • Joined: 23-August 12

Re: Hello World!

Posted 02 September 2012 - 08:45 PM

javac is the java compiler - it should create a Java executable (.class) from your .java source file.

To actually run it, you want to use java on your class file (I believe it'd be something like the following, but don't quote me - I don't often use Java from the command line):
java Welcome


I'd recommend getting set up with an IDE, such as Eclipse or Netbeans, while you're getting started and learning.

This post has been edited by Mina-no-Hime: 03 September 2012 - 02:42 AM

Was This Post Helpful? 0
  • +
  • -

#8 ILoveJava  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 389
  • Joined: 12-March 12

Re: Hello World!

Posted 03 September 2012 - 12:45 AM

After javac, you need to use java *filename* to actually run the name.
Was This Post Helpful? 0
  • +
  • -

#9 FalseOnlineID  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 8
  • Joined: 03-July 12

Re: Hello World!

Posted 03 September 2012 - 01:42 AM

javac welcome.java - this will compile the program
java welcome.java - this will execute the program

(in a minimal sense)
Was This Post Helpful? -2
  • +
  • -

#10 Mina-no-Hime  Icon User is offline

  • D.I.C Head

Reputation: 98
  • View blog
  • Posts: 176
  • Joined: 23-August 12

Re: Hello World!

Posted 03 September 2012 - 02:41 AM

FalseOnlineID, that is wrong. The .java file is the source file, so calling it with the java command will not execute anything.

To correct my earlier post (I'm also editing it), I was wrong in the inclusion of the file extension -- you'll want to do it as:
java Welcome

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1