Swaminathan K
asked on
Compile Java class importing class from different packages
Hi Team,
I have an java class called departments in an package called com.finance.departments package. Iam creating a type of departments in class called employee in org.hr.employee package. I need to compile the employee package with the
javac command , any help in this regard is appreciated.
Departments.java
--------------------------
package com.finance.Departments;
public class Departments
{
int Id;
String Dname;
}
Employee.java
---------------------
package org.hr.Employee;
public class Employee
{
int empId;
String empName;
Departments d;
}
Thanks in advance
I have an java class called departments in an package called com.finance.departments package. Iam creating a type of departments in class called employee in org.hr.employee package. I need to compile the employee package with the
javac command , any help in this regard is appreciated.
Departments.java
--------------------------
package com.finance.Departments;
public class Departments
{
int Id;
String Dname;
}
Employee.java
---------------------
package org.hr.Employee;
public class Employee
{
int empId;
String empName;
Departments d;
}
Thanks in advance
Your packages should probably be called com.hr and com.finance. You need the appropriate import statement in the Employee class for Departments (which should probably be called Department)
ASKER
Hi CEHI,
How do i compile a java code in different packages like the one I have shared. Is it possible?
How do i compile a java code in different packages like the one I have shared. Is it possible?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
awesome