We help IT Professionals succeed at work.

Run Java source from Linux on Eclipse IDE

cgray1223
cgray1223 asked
on
Hello,

I have some java source that gets build on a Linux machine using ant.  I want to be able to create eclipse projects for this source so I can debug it on my local pc.  What is the best approach for this?
Comment
Watch Question

Awarded 2011
Awarded 2011

Commented:
Create the project and import Java code into it add jars to depenednecies  and then compile and debug.
If there are some linux specific points - like filenames - you can modify those.
Mostly it should be starighforward
Awarded 2011
Awarded 2011
Commented:
check this description from:
http://stackoverflow.com/questions/142863/how-do-i-import-a-pre-existing-java-project-into-eclipse-and-get-up-and-running



Create a new Java project in Eclipse. This will create a src folder (to contain your source files).

Also create a lib folder (the name isn't that important, but it follows standard conventions).

Copy the ./com/* folders into the /src folder (you can just do this using the OS, no need to do any fancy importing or anything from the Eclipse GUI).

Copy any dependencies (jar files that your project itself depends on) into /lib (note that this should NOT include the TGGL jar - thanks to commenter Mike Deck for pointing out my misinterpretation of the OPs post!)

Copy the other TGGL stuff into the root project folder (or some other folder dedicated to licenses that you need to distribute in your final app)

Back in Eclipse, select the project you created in step 1, then hit the F5 key (this refreshes Eclipse's view of the folder tree with the actual contents.

The content of the /src folder will get compiled automatically (with class files placed in the /bin file that Eclipse generated for you when you created the project). IF you have dependencies (which you don't in your current project, but I'll include this here for completeness), the compile will fail initially because you are missing the dependency jar files from the project classpath.

Finally, open the /lib folder in Eclipse, right click on each required jar file and choose Build Path->Add to build path.

That will add that particular jar to the classpath for the project. Eclipse will detect the change and automatically compile the classes that failed earlier, and you should now have an Eclipse project with your app in it.
Awarded 2011
Awarded 2011

Commented:
I guess TGGL above was something specific to the question, but in general the same procedure

Author

Commented:
thanks for the responses for_yan....I should have been more descriptive in my question.  I was look for a way in eclipse to auto generate eclipse projects from my ANT build.xml files.  It looks like there is a way by creating a new project from Existing Ant Buildfile Eclipse wizard.  I have a master build.xml that calls other ones in sub directories.  When I try this wizard Eclipse complains saying "Specified buildfile does not contain a javac task" so I thought there may be a better way to do it via building on linux and then ftp the files over to my local pc and just do an import project in Eclipse.
Awarded 2011
Awarded 2011

Commented:
Maybe there is a way, but it will probably take more time figuring out than doing it in a sraightforward way. It is only if you are going to do that project moves on regular basis that it would pay off
CERTIFIED EXPERT
Top Expert 2016

Commented:
>> It looks like there is a way by creating a new project from Existing Ant Buildfile Eclipse wizard.  

That can be done as long as the build file is a conventional one. Sounds like yours isn't
Switch to NetBeans.  It has native support for opening Ant-based projects.  Not sure how well it handles nested ant scripts though.  Might want to consider looking into Maven.
CERTIFIED EXPERT
Top Expert 2016

Commented:
Yes, Netbeans certainly has better Ant support, being built from the ground up on Ant, but as Gordon says, nested stuff is not very likely to work out of the box
CERTIFIED EXPERT
Top Expert 2016

Commented:
It seems that an answer to a different question than the one posted has been accepted ..?

Explore More ContentExplore courses, solutions, and other research materials related to this topic.