Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

can I #include or import one of my own files?

843789Aug 4 2010 — edited Aug 8 2010
For example if I have the following setup:
/*
Path:   /mnt/e/java/include
Files:  X1.java   X2.java

/ ****  X2   "header" file  ****/
public class X2 {
    public static void extCall1() {
        System.out.println("dude");
    }
}

/****  X1  "main" file  ****/
import "/mnt/e/java/include/X2.*";  // is there a way to do something like this?

public class X1 
{ 
    include <X2>;                // or something like this?

    public static void main(String [] args)
    {
        extCall1();              // so this would be possible
        X2.extCall1();           // instead of this ? 
    }
}
Or is Java intentionally designed so that code will more clearly reflect its sources?
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 5 2010
Added on Aug 4 2010
16 comments
450 views