I have a basic package structure. I have Main class and Player class in first package 'pack1' and then in subdirectory 'pack2' I have a Monster class. I need to use javac and java commands when running this program because it's my homework, but it just tells me that package pack1.pack2 does not exist. I am trying to run it by using command 'javac Main.java'. If I remove packages and place them in the same folder, then the command 'javac Main.java' works fine. When I run this program by using Visual Studio Code "Run" command it runs fine.
My file structure looks like this:
pack1
|_ Main.java
|_ Player.java
|_ pack2
|_ Monster.java
I have been fighting with this for the past 2 hours now, trying to google different solutions but with no luck. I am probably using the javac command in a wrong way. I have tried using -d argument and some path arguments, but since I don't understand them clearly it probably was not the correct way of using them.
package pack1;
import pack1.pack2.Monster;
public class Main extends Monster {
public static void main(String[] args) {
killPlayer();
}
}
package pack1;
public class Player {
public void shout() {
System.out.println("Shout");
}
}
package pack1.pack2;
import pack1.Player;
public abstract class Monster {
public static void killPlayer() {
Player p = new Player();
p.shout();
}
}