Solved

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

Posted on 2012-03-15
12
505 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
Comment Utility
why don't you include the existing class files as a jar file and use them that way?
0
 

Author Comment

by:Lamiaaa
Comment Utility
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
Comment Utility
Does your jar file(s) conatin only classes or also source java codes ?
0
 
LVL 47

Expert Comment

by:for_yan
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 20

Expert Comment

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

Author Comment

by:Lamiaaa
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks guys
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

763 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

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now