Solved

Simple problem with Java packages

Posted on 2006-10-24
8
189 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
  • 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
hash value 2 39
countX 22 71
where is session ID cache stored 1 40
java  and programming certification ? 4 65
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
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 …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

743 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

10 Experts available now in Live!

Get 1:1 Help Now