Link to home
Start Free TrialLog in
Avatar of Swaminathan K
Swaminathan KFlag for India

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
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

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)
Avatar of Swaminathan K

ASKER

Hi  CEHI,

How do i compile a java code in different packages like the one I have shared. Is it possible?
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
awesome