package company;
public class Employee{
private int num;
public Employee(int newNum) {
setNum(newNum);
}
public int getNum() {
return num;
}
public void setNum(int newNum) {
num = newNum;
}
}
and there is my driver.
import company.*;
public class PrintEmployee {
public static void main(String[] args) {
Employee emp;
emp = new Employee(10000);
System.out.println(emp.getNum());
}
}
First, I compile Employee.java with javac *.java
.
Secondly, I am using jar -cf company.jar .\*.class
this command to create a JAR file.
After that, I am using javac -cp company.jar PrintEmployee.java
this command to compile it but it does not work.
PrintEmployee.java:1: error: package company does not exist
bad class file: C:\Users\user\Desktop\company\company.jar(/Employee.class)
How can I do it...