Coding error .

Flex Tron
Flex Tron used Ask the Experts™
Hello All  , I am a new learner in Java and trying to run this code .

import java.util.Scanner;

public class Employee {

    private String firstName;
    private String lastName;
    private double monthlySalary;

    public Employee(String firstName, String lastName, double monthlySalary) {
        this.firstName = firstName;
        this.lastName = lastName;

        this.monthlySalary = monthlySalary;

    public String getFirstName() {
        return firstName;

    public String getLastName() {
        return lastName;

    public double getMonthlySalary() {
        return monthlySalary;

    public class EmployeeTest {

        public void main(String[] args) {
            Scanner input = new Scanner(;

            System.out.print("Enter employee one's first name: ");
            String firstName = input.nextLine();
            System.out.print("Enter employee one's last name: ");
            String lastName = input.nextLine();
            System.out.print("Enter employee one's monthly salary: ");
            double monthlySalary = input.nextDouble();
            Employee employee1 = new Employee(firstName, lastName, monthlySalary);


            System.out.printf("Employee one's name: %s, %s%n",
                    employee1.getLastName(), employee1.getFirstName());

getting this error[b][b]:Error: Could not find or load main class employee.Employee.
Please if anybody can clarify me on code as to why this is coming up ?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
How are you trying to run it?

There is no declared package so it should be

java EmployeeTest

Open in new window

Flex TronDeveloper


Yes, It was needed to be declared and then it worked
Top Expert 2016


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial