0

I can see the version of my java site as well as javac:

➜  intro java --version
openjdk 13.0.2 2020-01-14
OpenJDK Runtime Environment (build 13.0.2+8)
OpenJDK 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)
➜  intro javac --version
javac 13.0.2

In the current directory(intro), I have an Account.java, as well as classes.java

Account.java:

package intro;

public class Account {

    private String name;

    public void setName(String name)
    {   
        this.name = name;
    }
    public String getName()
    {
        return name;
    }
    public static void main( String[] args) {       
        System.out.println("Printing the name here");
    }
}

classes.java:

package intro;
import java.util.Scanner;

public class classes {  
    public static void main( String[] args) {
        Scanner input = new Scanner(System.in);
        Account myAccount = new Account();
        System.out.printf("Initial name is: %s%n", myAccount.getName());
    }
}

I want to run the classes class, which uses methods from Account.java, and when I type the command bellow, nothing prints in the prompt.

➜  intro javac Account.java classes.java
➜  intro

EDITED: from my current directory I see the files am trying to execute if I run the ls command:

➜  intro ls
Account.class  Account.java   classes.class  classes.java   
welcome1.class welcome1.java

How do I run the classes.java via the prompt?

Arvind Kumar Avinash
  • 71,965
  • 6
  • 74
  • 110
Sidney Sousa
  • 3,378
  • 11
  • 48
  • 99

1 Answers1

0

javac will just compile the classes for you. Once you run

`javac Account.java classes.java`

You will get the .class files created. Now you should run the class file using the command

java classes
midhun mathew
  • 333
  • 1
  • 9