1 Attachment(s)
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
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?
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
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
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
Code :
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?
Re: n00b having problems running code
Quote:
Originally Posted by
djl1990
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:
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
Re: n00b having problems running code
Quote:
Originally Posted by
meathead
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
Code :
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.
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,
Code java:
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
Re: n00b having problems running code
Quote:
Originally Posted by
Freaky Chris
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,
Code java:
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.
Re: n00b having problems running code
Hi cha0s619,
Glad that solved your problem, would you please mark this thread as solved.
Thanks,
Chris
Re: n00b having problems running code
Quote:
Originally Posted by
Freaky Chris
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,
Code java:
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