Solved

Simple problem with Java packages

Posted on 2006-10-24
8
218 Views
Last Modified: 2010-03-31
Hi,

I have a class, classA (that is not in any package) that refers to another one of my classes, classB (also not in a package).
My problem is that when i put classA in a package, pack1, the complier says it cannot find the symbol classB. What am i doing wrong?

Thanks,
Michael
0
Comment
Question by:Xavior2K3
[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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 14

Expert Comment

by:hoomanv
ID: 17797830
path to A should be in classpath
0
 
LVL 1

Author Comment

by:Xavior2K3
ID: 17797846
Can you give me an example?
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 17798018
Sorry it seems that named package classes cannot access default package classes.
I'll look for a workaround
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Expert Comment

by:sciuriware
ID: 17798308
Public classes can be accessed by any other class.
You probably forgot to make them public.

;JOOP!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 17798313
And if JAVA can't find a class it's because the import statement is incorrect.

;JOOP!
0
 
LVL 14

Accepted Solution

by:
hoomanv earned 250 total points
ID: 17798340
The problem is that a named package class can not import a default package class and also classpath in this case wont help
0
 
LVL 9

Expert Comment

by:shinobun
ID: 17798816
1. Import the class:

import classB;

2. It is discouraged to make default package classes.  Just put it in a package.  (And import it!)
0
 
LVL 9

Expert Comment

by:shinobun
ID: 17798845
Unnamed packages are provided by the Java platform principally for convenience when developing small or temporary applications or when just beginning development.

http://java.sun.com/docs/books/jls/third_edition/html/packages.html#7.4.2
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

756 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