43

I want to get my NetBeans project to Eclipse. It's a web application project.

I imported war files into Eclipse but I am not able to get the Java files and the war files are giving me many errors. What is the best way to import the whole project?

Honza Zidek
  • 9,204
  • 4
  • 72
  • 118
XXDebugger
  • 1,581
  • 3
  • 26
  • 48

6 Answers6

31

One other easy way of doing it would be as follows (if you have a simple NetBeans project and not using maven for example).

  1. In Eclipse, Go to File -> New -> Java Project
  2. Give a name for your project and click finish to create your project
  3. When the project is created find the source folder in NetBeans project, drag and drop all the source files from the NetBeans project to 'src' folder of your new created project in eclipse.
  4. Move the java source files to respective package (if required)
  5. Now you should be able to run your NetBeans project in Eclipse.
moinul islam
  • 319
  • 3
  • 2
13

Sharing my experience, how to import simple Netbeans java project into Eclipse workspace. Please follow the following steps:

  1. Copy the Netbeans project folder into Eclipse workspace.
  2. Create .project file, inside the project folder at root level. Below code is the sample reference. Change your project name appropriately.

    <?xml version="1.0" encoding="UTF-8"?>
    <projectDescription>
        <name>PROJECT_NAME</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
            <buildCommand>
                <name>org.eclipse.jdt.core.javabuilder</name>
                <arguments>
                </arguments>
            </buildCommand>
        </buildSpec>
        <natures>
            <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
    </projectDescription>
    
  3. Now open Eclipse and follow the steps,

    File > import > Existing Projects into Workspace > Select root directory > Finish

  4. Now we need to correct the build path for proper compilation of src, by following these steps:

    Right Click on project folder > Properties > Java Build Path > Click Source tab > Add Folder

(Add the correct src path from project and remove the incorrect ones). Find the image ref link how it looks.

  1. You are done. Let me know for any queries. Thanks.
Hossam Ghareeb
  • 7,063
  • 3
  • 53
  • 64
Santosh Mondal
  • 319
  • 1
  • 6
  • 12
  • In case your source folder i.e. `src` is seen as a package after importing, you may have to remove it as source folder and add it again, in regards to step 4 of the solution above. – LivePwndz Oct 21 '16 at 05:31
11

You should be using Maven, as the structure is standardized. To do that (Once you have created your Maven project in Netbeans, just

  1. Go to File -> Import
  2. Open Maven tree node
  3. Select Existing Maven Project
  4. Browse to find your project from NetBeans
  5. Check Add project to Working Set
  6. Click finish.

As long as the project has no errors, I usually get none transferring to eclipse. This works for Maven web projects and regular projects.

Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
4

There's a very easy way if you were using a web application just follow this link.

just do in eclipse :

File > import > web > war file

Then select the war file of your app :)) very easy !!

muneeb_ahmed
  • 364
  • 5
  • 16
Chris Sim
  • 4,054
  • 4
  • 29
  • 36
2
  1. Make sure you have sbt and run sbt eclipse from the project root directory.
  2. In eclipse, use File --> Import --> General --> Existing Projects into Workspace, selecting that same location, so that eclipse builds its project structure for the file structure having just been prepared by sbt.
matanster
  • 15,072
  • 19
  • 88
  • 167
  • what is sbt? can you provide some links? – WVrock Mar 02 '15 at 16:32
  • 1
    [sbt](http://www.scala-sbt.org/download.html) is the de-facto Scala / TypeSafe build tool. It is misnomered Simple Build Tool whereas it is quite convlute to use in many common cases, and obscure for any getting started scenario as soon as you need to make your first tiniest change. But, mostly de-facto standardized and can do very cool things. A lot like Leiningen in the clojure world. Don't try to read the documentation of it, just use it and look for help when stuck. – matanster Mar 02 '15 at 17:22
  • @matt It's not enough to make sure I have sbt. I ran `sbt eclipse` and it just said `Not a valid command/project ID/key: eclipse`. To fix this, I had to follow the [instructions here](https://github.com/typesafehub/sbteclipse) to add sbteclipse to the global plugins config. Then I ran `sbt eclipse` and it worked: `Successfully created Eclipse project files for project(s)` – ADTC Aug 06 '15 at 04:43
1

In Eclipse:

File>Import>General>Existing projects in Workspace

Browse until get the netbeans project folder > Finish

Lemmy_Caution
  • 107
  • 2
  • 4