File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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: 2398
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 agree. Here's the link:
subject: Importing Classes in default package
It's not a secret anymore!