Solved

working with packages

Posted on 2004-04-02
4
204 Views
Last Modified: 2012-05-04
i have already created a package with the following line of code:

javac -d "d\folder1" MyClass1.java

the file has the package declaration statement 'package p1;' .it runs fine and it creates a package folder in d:\folder1.
Similarly i created 2 other classes(myClass2 and myClass3) in different files as all classes were public  and put them in the same package folder
 but the problem is when i try to access these classes from another file using  'import p1.*;' ,i get an error while if i write 'import p1.myClass1;' or myClass2/myClass3 the programn runs fine.i have already set the classpath varible to the package foler still the problem peersists. Why can't i use "p1.*" ?
0
Comment
Question by:uniqueaby
4 Comments
 
LVL 3

Expert Comment

by:eicheled
ID: 10744193
All of the source files in d:\folder1 should contain the line :

package p1;

(and of course, they should compile :) )

assuming that the resulting .class files are located in the same place (d:\folder1)
then if your CLASSPATH contains 'd:\folder1', all should be well.

Your other class should be able to access all the classes in the package with

import p1.*;

If you are still having trouble, post some code please.
0
 
LVL 30

Accepted Solution

by:
mayankeagle earned 20 total points
ID: 10755214
>> i have already set the classpath varible to the package foler

Have you set it to d:\folder1\p1 by any chance? You should set it to the parent-directory of the package-folder.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumHeights2  challenge 7 78
userCompare  challenge 3 62
count8 challlenge 13 87
nestparen challenge 4 57
This article will show, step by step, how to integrate R code into a R Sweave document
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now