Click here to Skip to main content
16,012,611 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...

I,m trying to run two files in dos promt,which are stored in two different packages...

both files are relay on each other...

I'm trying to set class path but not getting exact way...
C#
package p1;
class Box
{
    //public static void main(String args[]){
    int w=12;
    int d=30;
    int c=40;
//}
}

package p2;
import p1.Box;
class Demo
{
    public static void main(String[] args)
    {
        Box b=new Box();
        System.out.println("Hello World!");
    }
}
Posted
Updated 4-Oct-12 4:17am
v2

1 solution

Make both class as public,you cant access class outside the package if it is not public.Atleast make Box class as public

C#
package p1;
public class Box
{
//public static void main(String args[]){
int w=12;
int d=30;
int c=40;
//}
}



Command is java -cp c:\validation p2.Demo

where c:\validation folder is where both p1 and p2 folders are present.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900