LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Please Help (https://www.linuxquestions.org/questions/linux-newbie-8/please-help-904678/)

tootiemae 09-23-2011 02:35 PM

Please Help
 
I cant run Hello.java program in Fedora

public class Hello {

public static voild main(String[] args){
String name;
name= "Erica";
Systems.out.println("hello, +name+ "!");
}
}

anomie 09-23-2011 02:41 PM

If I may:
  1. Try using a more descriptive title than "Please Help"
  2. Please use code tags when posting source code snippets
  3. Explain what you've tried, and how it failed (i.e. Did you try running it from the command line? What did you type, exactly? What error message did it tell you?)

All that said, you appear to have at least two syntactical errors: a misspelled function definition, and a missing closing quote.

crts 09-23-2011 02:44 PM

Quote:

Originally Posted by tootiemae (Post 4480446)
I cant run Hello.java program in Fedora

public class Hello {

public static voild main(String[] args){
String name;
name= "Erica";
Systems.out.println("hello, +name+ "!");
}
}

Welcome to LQ.

Please use code-tags when posting code and/or data. What exactly do you mean? After correction of several errors it runs fine. Or are you not able to compile it? Keep in mind that Java also requires that the filenames have to follow this naming pattern:
classname.java

P.S.: The corrected version:
Code:

public class Hello {

 public static void main(String[] args){
  String name;
  name= "Erica";
  System.out.println("hello" +name+ "!");
 }
}


tootiemae 09-23-2011 02:49 PM

I cant compile the file i keep getting javac: file not found: Hello.java

crts 09-23-2011 02:56 PM

Quote:

Originally Posted by tootiemae (Post 4480460)
I cant compile the file i keep getting javac: file not found: Hello.java

As I already said, you need to follow this naming scheme in java:
classname.java

In your case you will have to name your file
Hello.java

and compile it with
javac Hello.java

Keep in mind that java is case sensitive.


All times are GMT -5. The time now is 07:18 AM.