Home > Back-end >  How to Import an External .class File in an Eclipse Java Project
How to Import an External .class File in an Eclipse Java Project

Time:10-14

I am trying to include a .class file through an import in a .java class I am creating. I need the .java class to look the same as what I need to deploy on the application server. I have created a directory structure to put the Context.class file in.

enter image description here

I updated the build path by using "Add External Class Folder..." and selected the "oracle" directory containing apps>fnd>common.

enter image description here

However, Eclipse still can't find the Context.class file referenced in the import.

enter image description here

What am I doing wrong?

CodePudding user response:

You need to select the classes (C:\Users\badams\java\classes) directory instead of the oracle directory when using Add External Class Folder....

You should provide the root of the directory that represent your java package structure.

As an alternative, you can create a jar archive with the contents of the C:\Users\badams\java\classes directory and add that archive as a jar dependency as well.

You can use for this purpose the builtin SDK jar utility. Please, change you current directory to C:\Users\badams\java\classes and run from a command prompt or PowerShell terminal something like:

jar cvf oracle-fnd.jar *

Then add the generated archive to your project as usual.

  • Related