Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: hello world script. probably really basic help

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy hello world script. probably really basic help

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







    I copied the above from a website because i am following a tutorial online and it was just showing me how to compile script. I am using Java jdk 1.7.0_25 and when i go into command prompt and "javac" the java file containing this hello world script i get this;

    "C:\Test>javac youtube.java
    youtube.java:3: error: unclosed string literal
    System.out.println("Hello World);
    ^
    youtube.java:3: error: ';' expected
    System.out.println("Hello World);
    ^
    youtube.java:5: error: reached end of file while parsing
    }
    ^
    3 errors"



    how is it that i copied a script from the internet yet i get errors? D:
    Last edited by jps; September 16th, 2013 at 06:57 PM. Reason: code tags


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: hello world script. probably really basic help

    Always treat a pile of errors as ONE error. The first error reported. In this case:
    unclosed string literal
    It means there is a literal string with the closing " missing.
    Once the compiler hits an error like this, the following errors may not be real errors. Fix the first (and considered only) error, and try to compile again. Then work on the first and only error again if there is one.

  3. #3
    Member
    Join Date
    May 2013
    Posts
    106
    My Mood
    Amused
    Thanks
    16
    Thanked 9 Times in 9 Posts

    Default Re: hello world script. probably really basic help

    How are you writing, compiling, and executing you code? Are you using an ordinary text browser? If so, yuck. Those make things immensely more difficult. Try using an IDE (integrated development environment) such as Eclipse (my personal preference, but I guess only because it's the only one I ever tried) or Netbeans. It looks like, as JPS said, you forgot to end a string with a quotation mark (you probably pasted the code then accidentally deleted it). With Eclipse (and probably Netbeans too), an error like that would be highlighted in the code window with a big ugly red underline and the IDE would warn you when you tried to launch.

  4. #4
    Member
    Join Date
    Jul 2013
    Location
    Mars
    Posts
    50
    My Mood
    Relaxed
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: hello world script. probably really basic help

    As someone who started out using eclipse then went to compiling and running codes through the terminal/command prompt i would recommend not starting out with an IDE. But this is coming from someone who was and still kind of is a complete noob with computers in general. By doing everything manually it forced me to see where my files are being saved and made me compile things on my own (rather than just clicking run). Being able to use the command line is just a good thing to know in general, too. Once i get better at writing code i will immediately jump back to an IDE because it really is the best way to go for professional use by far.

  5. #5
    Member Kewish's Avatar
    Join Date
    Apr 2013
    Location
    Australia
    Posts
    116
    Thanks
    10
    Thanked 17 Times in 14 Posts

    Default

    Looks like you're doing Bucky's tutorials too. He is entertaining for sure but be careful with his sloppy style, particularly in that Java for Beginners course.

    Just make sure you learn good coding practice like the naming of classes and the case you use. Classes should start with a capital letter.

    I feel his course would have been that much better if he pointed out stuff like that. At the same time it probably wouldn't have been as much fun to watch.

    One tutorial he even refers to ex girlfriends as fish1 and fish2. Crazy guy.

    Good luck OP

  6. #6
    Member
    Join Date
    Jul 2013
    Location
    Mars
    Posts
    50
    My Mood
    Relaxed
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: hello world script. probably really basic help

    In a class called tuna too i believe :/ Bucky is funny. A mixture of his tutorials and a few other sites isn't a bad route to take.

Similar Threads

  1. Help with my script
    By kuzbear in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 8th, 2013, 11:24 AM
  2. use readymade script in netbeans
    By ajaychhadwa in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: December 19th, 2012, 05:54 AM
  3. how to parse JSON using java script
    By mikeclark in forum Member Introductions
    Replies: 1
    Last Post: December 8th, 2012, 11:53 PM
  4. App needs to exec script
    By jocala in forum Android Development
    Replies: 0
    Last Post: July 5th, 2012, 09:01 PM
  5. Java Script or HTML
    By ravi9999 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 1st, 2012, 09:44 AM