Hello
i am totally noob at this i am trying to compile my first project but it has give me some error
http://s12.postimage.org/4js4u0apl/java.jpg
Printable View
Hello
i am totally noob at this i am trying to compile my first project but it has give me some error
http://s12.postimage.org/4js4u0apl/java.jpg
The compiler has a problem with this line:
Does something about that line look wrong to you?Code:System.out.println(Hello world!");
ya u r rigth it should be like this
Code:System.out.println("Hello world!");
it was giving me another error
http://s16.postimage.org/g5hp8d269/java.jpg
Please show your code and error messages in the forum as text, not as images, and please use [code] [/code] tags when doing so. The forum faq or my link below will explain how to do this. You can get the text from your cmd window easily by copying and pasting it.
As for your problem, the error message is telling you which identifier is not recognized, so you need to check, did you spell it correctly? If so, did you cApTaLiZe it correctly? Both matter.
Finally, please don't label your question "urgent" or anything similar as it suggests that you feel your question is more important than any other question here, and that's not being fair to the other folks who need help here.
Thanks for your cooperation in this.
Do you have stocks in optician equipment or something?
kind regards,
Jos
umm i dont see any problem in it may be u can point me out
Code:/* This is my First program*/
class myFirst {
public static void main (string [] args) {
System.out.println("Hello world!");
}
}
Just have a look at the spelling of a word in the parenthesis (brackets) of main.
You have written string and its actually a class in Java so it should be String. (i.e. S is capital)
Java is case-sensitive.
Yep. The error has a little hat symbol "^" under the "string" token notifying you that it is the offending bit. That should clue you into checking how it's spelled and capitalized.
it comes to me with another error
Code:C:\Documents and Settings\SK\My Documents>java MyFirst
Error: Could not find or load main class MyFirst
I am not really sure because it has been months that i haven't opened my Java book.
But then too i would like to pin-point some things
1) Its always bad to save files in the place where you are saving, its good to make a directory by your name in say D: drive and save all your .java (dot java) and .class (dot class) in it. Definitely Java has no problem where you are saving your files.
2) So are you sure that your .class (dot class) file which you got after successful compilation of your Java file, is in your same directory from which you are compiling through.
3) Anyways just try this and see
java -cp . myFirst
if it works.
( for this program don't change anything and start from step 2 of this post.)
yes the .class is there
and i tried the code u give it has given me error
Code:C:\Documents and Settings\SK\My Documents>java -cp . myFirst
Exception in thread "main" java.lang.NoClassDefFoundError: myFirst (wrong name:
MyFirst)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
I am unable to find any mistakes sorry!!!!!!!
But if you want then you can take a fresh start.
1) Just open a text editor like Notepad and write your program in it.
2) Save the file as myFirst.java in the place where you want or save it in D:\saif directory. (i will consider that you are saving your file here i.e. in D:\saif directory)
3) Open command prompt it will initailly point at c:\Documents and setting\................. etc, just type d: and press enter
4) Now you would see D;\ on command prompt. Now type cd saif and press enter
5) Now command prompt will have D:\saif>
6) Now compile your program
javac myFirst.java
7) Now execute it
java -cp . myFirst
ok i will try
same error no luck
solved get it working just a path problem