Java 如何将您的 Netbeans 项目导入 Eclipse

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21535023/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 09:13:02  来源:igfitidea点击:

How to get your Netbeans project into Eclipse

javaeclipsenetbeans

提问by XXDebugger

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

我想将我的 NetBeans 项目放到 Eclipse 中。这是一个 Web 应用程序项目。

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?

我将 war 文件导入 Eclipse,但无法获取 Java 文件,并且 war 文件给了我很多错误。导入整个项目的最佳方法是什么?

回答by Paul Samsotha

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

您应该使用 Maven,因为结构是标准化的。为此(在 Netbeans 中创建 Maven 项目后,只需

  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.
  1. 转到文件 -> 导入
  2. 打开Maven树节点
  3. 选择现有的 Maven 项目
  4. 浏览以从 NetBeans 中查找您的项目
  5. 选中将项目添加到工作集
  6. 单击完成。

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

只要项目没有错误,我通常不会转移到 eclipse。这适用于 Maven Web 项目和常规项目。

回答by matanster

  1. Make sure you have sbt and run sbt eclipsefrom 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.
  1. 确保你有 sbt 并sbt eclipse从项目根目录运行。
  2. 在eclipse中,使用File --> Import --> General --> Existing Projects into Workspace,选择相同的位置,以便eclipse为sbt刚刚准备好的文件结构构建它的项目结构。

回答by moinul islam

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

另一种简单的方法如下(例如,如果您有一个简单的 NetBeans 项目并且不使用 maven)。

  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.
  1. 在 Eclipse 中,转到文件 -> 新建 -> Java 项目
  2. 为您的项目命名,然后单击完成以创建您的项目
  3. 创建项目后,在 NetBeans 项目中找到源文件夹,将 NetBeans 项目中的所有源文件拖放到 eclipse 中新创建的项目的“src”文件夹中。
  4. 将 java 源文件移动到相应的包(如果需要)
  5. 现在您应该能够在 Eclipse 中运行您的 NetBeans 项目。

回答by Chris Sim

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

如果您使用的是 Web 应用程序,则有一个非常简单的方法,只需点击此链接即可

just do in eclipse :

只需在 eclipse 中执行:

File > import > web > war file

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

然后选择您的应用程序的 war 文件 :)) 非常简单!

回答by santosh mondal

Sharing my experience, how to import simple Netbeansjava project into Eclipseworkspace. Please follow the following steps:

分享我的经验,如何将简单的Netbeansjava 项目导入Eclipse工作区。请按照以下步骤操作:

  1. Copy the Netbeans project folder into Eclipse workspace.
  2. Create .projectfile, 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

  1. 将 Netbeans 项目文件夹复制到 Eclipse 工作区。
  2. 在根级别的项目文件夹内创建.project文件。下面的代码是示例参考。适当更改您的项目名称。

    <?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. 现在打开Eclipse并按照步骤操作,

    文件 > 导入 > 现有项目到工作区 > 选择根目录 > 完成

  4. 现在我们需要通过以下步骤更正构建路径以正确编译 src:

    右键单击项目文件夹 > 属性 > Java 构建路径 > 单击源选项卡 > 添加文件夹

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

(从项目中添加正确的 src 路径并删除不正确的路径)。查找图像参考链接的外观。

  1. You are done. Let me know for any queries. Thanks.
  1. 你完成了。如有任何疑问,请告诉我。谢谢。

回答by Lemmy_Caution

In Eclipse:

在日食中:

File>Import>General>Existing projects in Workspace

文件>导入>常规>工作区中的现有项目

Browse until get the netbeans project folder > Finish

浏览直到获得 netbeans 项目文件夹 > 完成