First of all, the code you posted shows child_class declared as being in package p1, not p2. Also, fully qualified package and class names are expected to match the file system structure and locations of source files in folders.
That is, if you have p1 and p2 which you want to have the classes inherit and child_class, respectively, the folder structure and sources files should look something like this:
../p1/inherit.java
../p2/child_class.java
where .. is the path of the folder from which you compile your code.
Classes in the same package can reference each other without an
import. You only need an import if the class being referenced is in a different package. Finally, as it is now, child_class cannot reference x because child_class does not extend the inherit class.
One last note:
you should try to follow
common Java naming conventions