Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

nested Packages  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
file:=Test1.java
package testPack;//this is the outer package
public class Test1
{
public Test1()
{
System.out.println("I am the first class constructor in the parent package");
}
}
//the below file I saved under the above package directory and compiled
file:=Test2.java
package testPack1;//this is the inner package
public class Test2
{
public Test2()
{
System.out.println("I am the first class constructor in the next package");
}
}
//both the packages got created and the below file compiled with the classpath specified.
file:=NestPack.java
import testPack.*;
import testPack.testPack1.*;
public class NestPack
{
public static void main(String args[])
{
testPack.Test1 t1=new testPack.Test1();
testPack1.Test2 t2=new testPack1.Test2();
}
}

when executing the above file it displays the contents of first class ,but the Test2 class there is an error
NoClassDefinedFoundError Exception
Please help me out.
------------------
believe in the best
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following setup :
In G:\testPack directory :
I have Test1.java compiles to Test1.class (compiles fine). Classpath set to g:\
In g:\testPack\testPack1
I have Test2.java compiles to Test2.class (compiles fine).
In g:\testPack
I have NestPack.java compiles to NestPack.class (compiles fine). As there is not package statement in this file, can be placed here.
HTH
 
Bharatesh H Kakamari
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also prints :
I am the first class constructor in the parent package
I am the first class constructor in the next package
 
eshuVenkatRamani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Bharatesh H Kakamari:
Also prints :
I am the first class constructor in the parent package
I am the first class constructor in the next package


thankyou for the answer.
i am saving test1.class in c:\testPack directory.
i am saving test2.class in c:\testPack\testPack1 directory.
i am saving NestPack.java in c: directory
when I am executing It displays only the parent package class constructor and gives error for inner package class constructor.
Just try this and reply me soon
thankyou
eshu
------------------
believe in the best
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!