File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes A problem with package visiblitly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "A problem with package visiblitly" Watch "A problem with package visiblitly" New topic

A problem with package visiblitly

Femi Alla
Ranch Hand

Joined: Jul 05, 2002
Posts: 79
Hello everyone.
This question ended up being so long. But there's no way else I could have put forward the question.
In my daily programming practice, I was trying to create a kind of multithreaded application..... Put it in a folder/directory which has two subdirectories in which there are other applications which both display the output of a counter. And in the parent directory, I put the main application which activates the other two. This had worked perfectly well with all of them in the same folder. This was when I ran into problems. It just didn't different folders that is.
The parent folder is called TheMultithreadedExperiment, and the other folders it contains are "Folder1" and "Folder2". The main one that calls the others is and the others are (which is in Folder1) and (in Folder2).
The codes are below. The compiler messages are below the programs.
Please do take a look.
Please meet
/** Here, I was trying to put threaded programs
in the diferrent folders and let one main program active the others,
and display what is going on in the different folders.

this is the one in Folder1

This is the one in Folder2.

The files reside in C:\JavaPrograms\PersonalPractice\PersonalExperiments\TheMultithreadedExperiment
The error messages I got for the version of this programs pasted up here was:
javac cannot access InFolder1.InFolder1
bad class file: .\InFolder1\InFolder1.class
class file contains wrong class: JavaPrograms.PersonalPractice.PersonalExperimen
Please remove or make sure it appears in the correct subdirectory of the classpa
import InFolder1.InFolder1;
1 error
This was even after I had used the command set classpath = C:\JavaPrograms\PersonalPractice\PersonalExperiments\TheMultithreadedExperiment
Before this, I had even made the import statement look like this in the two child programs:
import JavaPrograms.PersonalPractice.PersonalExperiments.TheMultithreadedExperiment and then the error messages were better, I guess. It was something along the lines of "package JavaPrograms.PersonalPractice.PersonalExperiments.TheMultithreadedExperiments.InFolder1 does not exist." But I decided to change this 'cos I reasoned that the dots (.) in an import statement is meant to separate subclasses (or is it packages?).
I really need help here. Can any one figure out what's wrong?
(edited by Cindy to format code)
[ July 24, 2002: Message edited by: Cindy Glass ]

Snigdha Solanki
Ranch Hand

Joined: Sep 07, 2000
Posts: 128
The import statements are wrong. It should be
import InFolder1.InFolder1;
import InFolder2.InFolder2;
Although is in directory Folder1
but the package statement does not include that.If you say
package InFolder1;
then the class file will be created in a directory
javac -d .
will create a directory InFolder1 and put InFolder1.class file in it.

Hope this helps.

Snigdha<br />Sun Certified Programmer for the Java™ 2 Platform
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

also, the classes and need to be declared public -- otherwise they won't be accessible by
Once you fix the above errors, you'll get a few more compile-time errors due to typos in -- but you should be able to fix those by the descriptive error messages.
Lastly -- check out the handy dandy UBB [CODE] tags -- they help preserve whitespace and improve code readability.
Femi Alla
Ranch Hand

Joined: Jul 05, 2002
Posts: 79
Thanks a lot. It worked.
I agree. Here's the link:
subject: A problem with package visiblitly
jQuery in Action, 3rd edition