Solved

working with packages

Posted on 2004-04-02
4
218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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:
Mayank S 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

739 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