0

//i have written this code in package p1::
//address of this file is:::C:\p1

package p1;
public class balance{
String name;
double bal;
public balance(String n,double b)
{
name=n;
bal=b;
}
}


//and now i want to import this file in this code
//address of this file is:::C:\Program Files\Java\jdk1.6.0_11\bin
import p1.*;

class testbal
{
public static void main(String args[]){
balance test=new balance("ahmed",99.88);
}
}


plz tell how to execute this imported package file in cmd.

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by musthafa.aj
0

you'll need to place the package p1 somewhere the compiler of the second application can find it.
also, you might want to put a print-instruction in the balance constructor or at the end of the main method, just to check whether or not the program does what you intend it to do.

0

you should specify the supporting class file location to the current class..

suppose your class1 in folder exam/doit/

then you want add class1 to the current class class2..

then your class2 package declaration like this..

import exam.dot.*;

or

import exam.dot.class1;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.