• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

Package issue

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm facing a strange problem in my small application...

where i've created 4 classes in two java files 1 file having 1 public scope class, and the other is having two package scope and one public class.
This application executes successfully at my home pc, but when this is run on my institute's pc (i've tried two pcs there), the classes defined in different files doesn't recognize each other at compilation, but when the whole code is combined into a single file the program again compiles successfully...

I've checked the package statement in both files and it was correct...!!
please someone tell me how to solve this problem...!!
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there and welcome to Javaranch!

Can you please change your screen name in accordance with our Naming Policy, thanks

As to your question, can you please post your code? Especially the multiple file version.
 
Brij Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you...!!
The code (multiple files) is:



When these files are compiled, Indexer.java files gives compilation error regarding unrecognized symbols KeyStoreTable and CrawlTable.
But when the Indexer class definition is included in WebCrawler.java file(ommiting public modifier), this file compiles without any error and also runs with the updates made in definition.
Each file compiles on my home pc, but compilation error occures on my institute's pc.

I have also a small class (serving as an entry point to execution) in same package in another file, the same problem also occured with it. I've used package concept in many small applications before this.
 
Marshal
Posts: 77953
373
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know. What version of javac are you using at home and at work?
 
Brij Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually at work place there was no jdk installed, but jre (don't exactly know the jre version, but it was not 1.5.0_06) was there...and no permission to install any software...!!
so I had copied jdk1.5.0_06 from home to institute pc and on both pcs, OS is windows.
Does jdk version affect package concept...?
 
author
Posts: 23937
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Brij Patel wrote:Actually at work place there was no jdk installed, but jre (don't exactly know the jre version, but it was not 1.5.0_06) was there...and no permission to install any software...!!
so I had copied jdk1.5.0_06 from home to institute pc and on both pcs, OS is windows.
Does jdk version affect package concept...?



The java compiler is a java program -- you can't just copy the compiler, without any of the support classes. If you want the compiler to run, you will need to install the JDK, or copy everything from the java home directory of your home computer.

Henry
 
Brij Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm writing this from institute's pc...!!

I've copied the whole jdk1.5.0_06 and jre1.5.0_06 folders, set the path...
and triedd this simple test...,




compiled file B.java successfully,
while compiling A.java I get the following error:

cannot find symbol
symbol: class B
location: class pactest.A
new B ();

I think I've done everything perfect now, but still problem persists, and after combining these definitions into a single file the program compiles and runs successfully...!!
Now i don't know what to do...!!
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, in which directories do A.java and B.java sit in?
 
Brij Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both files are in:
D:\SE\pactest


jdk and jre folders are in:
D:\SE

path=D:\SE\jdk1.5.0_06\bin;
 
Brij Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh.... i forgot to try 'cp'
this solved my problem: javac -cp .; A.java

Thank you very much for your resposes...
this made me not to leave the problem...!!
again Thank you..!!
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad we could help and well done on solving it!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic