Solved

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

Posted on 2012-03-15
12
510 Views
Last Modified: 2012-03-20
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.
0
Comment
Question by:Lamiaaa
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 37725801
why don't you include the existing class files as a jar file and use them that way?
0
 

Author Comment

by:Lamiaaa
ID: 37726044
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?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37726068
Does your jar file(s) conatin only classes or also source java codes ?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Expert Comment

by:for_yan
ID: 37726082
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
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 37726147
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
0
 

Author Comment

by:Lamiaaa
ID: 37726213
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?
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 37726277
press ctrl + shift + O------> eclispe automatically import ur package...
0
 

Author Comment

by:Lamiaaa
ID: 37726429
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?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 37726562
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
0
 
LVL 47

Accepted Solution

by:
for_yan earned 500 total points
ID: 37726627
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
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 500 total points
ID: 37726642
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
0
 

Author Closing Comment

by:Lamiaaa
ID: 37742116
Thanks guys
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question