Code from the Java Core Technology volume
The abstract is represented as follows:
Managertest.java
Package inheritance;
...
public class Managertest
{
}
stored in: Inheritance/managertest.java
Manager.java
Package inheritance;
...
public class Manager
{
}
stored in: Inheritance/manager.java
Employee.java
Package inheritance;
...
public class Employee
{
}
stored in: Inheritance/employee.java
Okay, now compile it.
Javac *.java
Symbol not found
What do you mean?
Which means these three classes are placed in a folder inheritance.
One next to one
But when you compile, you don't see each other.
Well, how do we fix it?
Programme one:
Three classes are still thrown together in the inheritance folder
Comment out the package inheritance at the beginning of the three classes for example://package inheritance;
Compile javac *.java again
Scenario Two:
The class that will need to run the main () function refers to the outside of the folder
This is Managertest.java .
Take my experiment as an example:
The path to my computer is
F:\java1\fivecptr\fivecptrone\Inheritance (three classes in this)
I put Managertest.java in the java1 folder.
F:\java1\fivecptr\fivecptrone\Inheritance (remaining 2 classes)
....... ↑----------.....
Managertest.java
Then modify the code as follows
Inheritance two-class package changed to:
Package fivecptr.fivecptrone.inheritance;
....... __________↑_____________
F:\java1\fivecptr\fivecptrone\inheritance
is to copy the path behind the Managertest.java class. Of course "\" replaced by "."
TIPS: path names can not have strange symbols such as: underline _, Arabic numerals 0,1 ... (So fivecptr--!) with egg-ache
Next:
JAVA1 inside the managertest.java inside
1) Comment out package//package inheritance;
2) Add import fivecptr.fivecptrone.inheritance at the beginning. *; (As above, add the wildcard character at the end *)
Next, set the class path
(under Win7)
Computer-(left) computer right-Properties-Advanced system settings-environment variables-System variables-NEW
Name: CLASSPATH;
Path: F:JAVA1;.; (That is, the Managertest.java that class is located in the folder JAVA1 before-including the java1-path to write up, you can add another.; (Period + semicolon, if the scenario does not work, it may be the problem here, it represents the search class in the current directory)
Are you sure
Re-open Console (black box--!) )
CD to Managertest.java under File path
Run:
Javac Managertest.java
This article is from the "Kivilin_it_start" blog, make sure to keep this source http://kivilin.blog.51cto.com/6914610/1629991
Compiler is not compiled under package inheritance in Java solution