How can I import a directory/sub-directory of a java application into eclipse?

The application is made of packages/sub-packages. I have tried multiple time but with no success. each time I get an error (like "the selection cannot be launched" OR "The declared package does not match the expected package").

What I want is to be able to modify the application and run it from eclipse.

Your help is appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurvinder Pal SinghCommented:
why don't you include the existing class files as a jar file and use them that way?
LamiaaaAuthor Commented:
Sorry, but I am relatively new to java/eclipse.

I want to "modify" not only "use" the classes, would that still be possible?
If yes, can you please give me the steps that I should follow?
Does your jar file(s) conatin only classes or also source java codes ?
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

If you have java source code files  you can importa them into Eclipse project , modify, compile and run in Eclipse. If you have classfiles they are not supposed to be edited, then can only be executed. You can decompile them to java code and then work with the source - but that is normally not advisable way
Gurvinder Pal SinghCommented:
Unless you create those packages in your source folder of eclipse project, you cannot modify the source code.

If you want to use their functionalities and add some new ones, then inherit those classes and override those methods which you want to modify and add those methods which were not available earlier
LamiaaaAuthor Commented:
Thanks guys..

It does contain java source code files and I did try to import them many times. However, each time I got an error like: "the selection cannot be launched" OR "The declared package does not match the expected package".

How can I make sure they are imported properly?
Sathish David Kumar NArchitectCommented:
press ctrl + shift + O------> eclispe automatically import ur package...
LamiaaaAuthor Commented:
I am now getting the error: (the import org.math cannot be resolved) and (the import org.jdom cannot be resolved)...

How can I resolve this problem?
How can I resolve this problem?

Add the jars of the apis in question to the project. In the latter case, it's JDom. In the former case, i've no idea
Extract all your java files into some folder hierarchy
Create the Java project in Eclipse

right click on the src folder - go to import - General - File folder - browse to the top level
folder of your soource - say select all and import all your Java sources

If you have third partuy jar depnendencies those need to be added also as dedepmnendecies

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
To add the third-party jars go to the project name in navigation panel 9not to the src folder)
and then right clikc - got to Build Path-- Configure Build Path - select Libarary tab on te top,
click on Add external Jars and brows to the external jar which needs to be added
LamiaaaAuthor Commented:
Thanks guys
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.