0

Is it possible to run in terminal java program that contains multiple files? When I'm using

javac main.java

terminal can't find any files except main.java

DzikiChrzan
  • 2,747
  • 2
  • 15
  • 22

1 Answers1

3

First you compile your .java files

javac *.java

then you run it by typing,

java main

where main is the class with your main method, in the terminal.

mattias
  • 2,079
  • 3
  • 20
  • 27
  • But when i use 'javac main.java' I have an error "cannot find symbol" (it becouse it couldn't find class from another file). – DzikiChrzan Jun 04 '15 at 20:41
  • And that is why you type `javac *.java` to get all the java files within the same directory compiled together. – mattias Jun 04 '15 at 20:43