Java The Solution

Jamal Desir
Jamal Desir
1,184 Points

bash: Greeter.java: command not found?

For some reason, it gives me the message "bash: Greeter.java: command not found" when I run the code. Did i do something wrong? Here's my code:

import java.io.Console;

public class Greeter {

public static void main(String[] args) { Console console = System.console();

String place = "Walmart";
String firstName = console.readLine("What is your first name:  ");
console.printf("Hello %s! Welcome to %s. %n" , firstName , place);

}

}

You did run command correctly? after you saved your file. I mean: javac <name>.java && java <name>

Codrin Postu
Codrin Postu
8,020 Points

You most probably wrote in bash "Greeter.java" which is incorrect.

To run the program you need to first compile it using "javac Greeter.java" and then run it with "java Greeter"