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 11 of 11

Thread: n00b having problems running code

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default n00b having problems running code

    Hi,

    I'm new to Java & programming in general (only done bash for 2 months). I downloaded Java 6 and the Eclipse IDE. I'm reading some books and watching tutorial vids online. However, no code I try works and I can't figure out why. I'm copying & pasting directly from the tutorials and I'm getting strange errors. Please see the attached screenshot.

    Thanks

    P.S. I use Ubuntu 10.04
    Attached Images Attached Images


  2. #2
    Member
    Join Date
    Oct 2011
    Posts
    114
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: n00b having problems running code

    Could you highlight over the little red 'i' and what does it say or what is it hinting at you?

    Also have you declared what package this class is in?

  3. #3
    Member
    Join Date
    Oct 2011
    Posts
    114
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: n00b having problems running code

    I cant make out some of the symbols you have could you copy and paste the code, the attatched picture is a bit blury

  4. #4
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: n00b having problems running code

    Hi cha0s619,

    Please paste all of your code as djl request.

    Please not you should make your class 'public'.

    Regards,
    Chris

  5. #5
    Member
    Join Date
    Jul 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: n00b having problems running code

    You are brave to try on your own. I don't do Eclipse. could you perhaps use notepad (included with Windows) to do a Hello World type program?

    Save as: Hello.java

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

    If you have been knocking your head against this cor a couple of months, you have discovered that the compiler is looking for any excuse to fail. Upper/lower case makes a difference. Punctuation makes a difference, etc.

    to compile, if Hello.java would be in the same directory as javac.exe (the compiler) the syntax in DOS/command line window would be:

    javac Hello.java

    This will attempt to compile the file and produce a file called Hello.class javac will either come back with an error or return a prompt without a word, which signifies a successful compile. If it compiles successfully, you are free to run the program. You do this with

    java Hello


    If it successfully runs, it will repeat the message in the quotes, and terminate with returning to a command prompt.


    Can you get this far?

  6. #6
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: n00b having problems running code

    Quote Originally Posted by djl1990 View Post
    Could you highlight over the little red 'i' and what does it say or what is it hinting at you?

    Also have you declared what package this class is in?
    ""Multiple markers at this time:
    -println cannot be resolved or is not a field
    -Syntax error, insert ";" to complete BlockStatements
    -Syntax error, insert "AssignmentOperator Expression" to complete Assignment""

    The code:

     
    public class Displayer {
     
    	public static void main(String args[]) {
    		System.out.println(“You’ll love Java!”);
    	}
    }

    I had left out making the class public, but even after correcting that it's still not working


    Thanks for the help so far

  7. #7
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: n00b having problems running code

    Quote Originally Posted by meathead View Post
    You are brave to try on your own. I don't do Eclipse. could you perhaps use notepad (included with Windows) to do a Hello World type program?

    Save as: Hello.java

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

    If you have been knocking your head against this cor a couple of months, you have discovered that the compiler is looking for any excuse to fail. Upper/lower case makes a difference. Punctuation makes a difference, etc.

    to compile, if Hello.java would be in the same directory as javac.exe (the compiler) the syntax in DOS/command line window would be:

    javac Hello.java

    This will attempt to compile the file and produce a file called Hello.class javac will either come back with an error or return a prompt without a word, which signifies a successful compile. If it compiles successfully, you are free to run the program. You do this with

    java Hello


    If it successfully runs, it will repeat the message in the quotes, and terminate with returning to a command prompt.


    Can you get this far?
    Yes! This works. Thanks. But how do I get it to work in Eclipse? I tried some code in NetBeans earlier and it was working as well.

  8. #8
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: n00b having problems running code

    Hi cha0s619,

    You may find that you have an "invalid" character in your Java program you were trying to compile in eclipse. Looking at this line,
    System.out.println(“You’ll love Java!”);

    Edit: see how the syntax highlighter hates those characters!

    notice the ” character, this is not the same as " make sure you are using " and avoid copying code from websites/pdfs/.docs

    I hope this helps you resolve the problem with Eclipse, if it doesn't let us know .

    Regards,
    Chris

  9. #9
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: n00b having problems running code

    Quote Originally Posted by Freaky Chris View Post
    Hi cha0s619,

    You may find that you have an "invalid" character in your Java program you were trying to compile in eclipse. Looking at this line,
    System.out.println(“You’ll love Java!”);

    Edit: see how the syntax highlighter hates those characters!

    notice the ” character, this is not the same as " make sure you are using " and avoid copying code from websites/pdfs/.docs

    I hope this helps you resolve the problem with Eclipse, if it doesn't let us know .

    Regards,
    Chris
    Thanks it's working now.

  10. #10
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: n00b having problems running code

    Hi cha0s619,

    Glad that solved your problem, would you please mark this thread as solved.


    Thanks,
    Chris

  11. #11
    Junior Member
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: n00b having problems running code

    Quote Originally Posted by Freaky Chris View Post
    Hi cha0s619,

    You may find that you have an "invalid" character in your Java program you were trying to compile in eclipse. Looking at this line,
    System.out.println(“You’ll love Java!);

    Edit: see how the syntax highlighter hates those characters!

    notice the ” character, this is not the same as " make sure you are using " and avoid copying code from websites/pdfs/.docs

    I hope this helps you resolve the problem with Eclipse, if it doesn't let us know .

    Regards,
    Chris
    interesting solution and it works

Similar Threads

  1. Really Quick n00b question, should take three seconds to answer
    By joeschmidt45 in forum Java Theory & Questions
    Replies: 4
    Last Post: February 24th, 2011, 05:23 AM
  2. HELP! Gui is running fine, don't know exactly how to code.
    By cc11rocks in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 12th, 2011, 02:12 PM
  3. Problems with Code?
    By Sean137 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: December 14th, 2010, 03:15 PM
  4. Textpad Program Running Problems
    By Paddy in forum Java IDEs
    Replies: 4
    Last Post: January 27th, 2010, 09:14 PM
  5. Java n00b
    By Campos in forum AWT / Java Swing
    Replies: 6
    Last Post: July 22nd, 2009, 09:26 AM