0

Under the root directory, there are two directories named src and classes.

I have two java files named Master and Slave.

Slave file is under the directory src/com/example/web and compiled master file is under the directory classes/com/example/model.

I have compiled the master class is used. In Slave.java, Master class is used with the help of

import com.example.model.Master

But while compiling in the root directory using

javac -classpath classes -d classes src\com\example\web\Slave.java

the following error is thrown:

package com.example.model does not exist

Naveen
  • 38
  • 8

1 Answers1

0

if you know the Hierarchy of dependeny , you should build all classes based on dependency. in this case yous should execute this commands sequential :

first

javac -classpath classes -d classes src\com\example\model\Master

then

javac -classpath classes -d classes src\com\example\web\Slave.java

if you have more than a class in packages you can build all with wild cards. for example:

javac -classpath classes -d classes src\com\example\model\*.java
reza ganji
  • 11
  • 2
  • Sorry I have not mentioned in the question but I compiled the master first and then I compiled the slave but it didn't worked. – Naveen May 05 '19 at 13:12