This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Importing Classes in default package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Importing Classes in default package" Watch "Importing Classes in default package" New topic

Importing Classes in default package

swarna dasa
Ranch Hand

Joined: Mar 15, 2007
Posts: 108
Is there a way to import classes in default package (having no package statement at all)?

Have a file

public class Test {

Have another file Test2 in package com

package com;
public class Test2 {
public static void main(String[] args) {
//Test test = new Test();

Is there any way of importing
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
No you cannot import them unless they are in a package.

As long as the directory containing the .class file is in the CLASSPATH, you should be able to use the type.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Importing Classes in default package
It's not a secret anymore!