0

enter image description here

while I was practicing some basic input method, came across this error message posted in the title:

when it ran javac InputAddress.java ; it complies correctly, but when I ran javac InputAddress, it gives me that error message.

here is my code:

package inputaddress;

import java.util.*;

public class InputAddress
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter name: ");
        String navn = in.nextLine();
        System.out.print("Enter address: ");
        System.out.print("Enter zipcode: ");
        String postnr = in.nextLine();
        String adres = in.nextLine();
        System.out.print("Enter town:   ");
        String bynavn = in.nextLine();
        System.out.println();
        System.out.println("Address:");
        System.out.println();
        System.out.println(" Name:      " + navn);
        System.out.println(" Address:   " + adres);
        System.out.println("            " + postnr + "  " + bynavn);
    }
}
  1. I am using Notepad++/Sublime for writing the code, build in terminal for running the code ... (I do have Eclipse/Netbeans, but I am trying to overcome this issue,instead of avoiding it)
  1. if I compile and run other file *in the same folder using the same commands, it works just fine. i.e. there is a file named Exercise1.java; if I run javac Exercise1.java; and run java Exercise1.class works no problem.
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 1
    I'm not a Java programmer, but I'm an expert in several other programming languages. If it works fine in the same folder but not when you put it in a different folder, there must be some mechanisms in Java for controlling where it looks for the modules you want to import. – royce3 Feb 13 '21 at 17:57
  • Your class is not called `InputAddress`, it's called `inputaddress.InputAddress`. – Mark Rotteveel Feb 15 '21 at 11:40

0 Answers0