You've said run the class HelloWorld from mypackage by typing the following:
C:\mypackage> java mypackage.HelloWorld
This will again introduce java.lang.NoClassFoundError as we are telling the JVM to find HelloWorld inside mypackage, which inturn is inside folder called mypackage.
Thus the command should be:
C:\java mypackage.HelloWorld
Sir This is my program
I saved this program in the DIR:
D:\Java\jdk1.6.0\bin\Mypack\AccountBalance.java
The problem is how should i run this program using cmd?
I tried your instruction but it fails to run!
Please Give ME solution
package Mypack;
class Balance
{
String name;
double bal;
Balance(String n,double b)
{
name=n;
bal=b;
}
void show()
{
if(bal<0)
System.out.print("-->");
System.out.println(name+":$"+bal);
}
}
class AccountBalance
{
public static void main(String args[])
{
Balance current[]=new Balance[3];
current[0]=new Balance("K. J. Fielding",123.23);
current[1]=new Balance("Will Tell",157.02);
current[2]=new Balance("Tom Jackson",-12.33);
for(int i=0;i<3;i++) current[i].show();
}
}
import two classes with identical class then you have to tell for object creation explicitly the package name for at least
one class object...
for example: two packages package1,package2 both containing class,named class
then import package1.class1;
import package2.*;// * here applicable
class1.pk1=new class1();
package2.class1=new package2.class1();
here package2 explicitly told
Creating Own PackageJEDI March 30, 2011 at 12:46 AM
One should have to restart their command prompt to execute the java file contained in the package after setting the CLASSPATH.
Thank youDipali Hadkar April 14, 2011 at 3:13 PM
Very good explanation
Using mypackage.HelloWorld to run your programGinna Yadav November 25, 2011 at 9:55 PM
You've said run the class HelloWorld from mypackage by typing the following: C:\mypackage> java mypackage.HelloWorld This will again introduce java.lang.NoClassFoundError as we are telling the JVM to find HelloWorld inside mypackage, which inturn is inside folder called mypackage. Thus the command should be: C:\java mypackage.HelloWorld
how do i import this packagetara March 26, 2012 at 11:13 PM
so can i import this package simply using the name of the package or should i use the full path
how to import it tara March 26, 2012 at 11:28 PM
how to import this package from another class
Package Program-Ashwin April 23, 2012 at 1:41 PM
Sir This is my program I saved this program in the DIR: D:\Java\jdk1.6.0\bin\Mypack\AccountBalance.java The problem is how should i run this program using cmd? I tried your instruction but it fails to run! Please Give ME solution package Mypack; class Balance { String name; double bal; Balance(String n,double b) { name=n; bal=b; } void show() { if(bal<0) System.out.print("-->"); System.out.println(name+":$"+bal); } } class AccountBalance { public static void main(String args[]) { Balance current[]=new Balance[3]; current[0]=new Balance("K. J. Fielding",123.23); current[1]=new Balance("Will Tell",157.02); current[2]=new Balance("Tom Jackson",-12.33); for(int i=0;i<3;i++) current[i].show(); } }
plush toy pachagerosie May 9, 2012 at 7:14 PM
big and colourful
javasunit mondal May 14, 2012 at 10:40 PM
i am astudent
sagarsagar August 7, 2012 at 7:54 PM
hello
javapadmarag August 22, 2012 at 9:25 PM
to run package i have to come out of the package directory then type incommand prompt,here intis case(example mypackage) c:\>java mypackage.HelloWorld
"java packages with identical method"padmarag August 22, 2012 at 11:00 PM
import two classes with identical class then you have to tell for object creation explicitly the package name for at least one class object... for example: two packages package1,package2 both containing class,named class then import package1.class1; import package2.*;// * here applicable class1.pk1=new class1(); package2.class1=new package2.class1(); here package2 explicitly told
Post your Comment