How do I build a Java project in Eclipse, to create an external JAR

后端 未结 5 1061
抹茶落季
抹茶落季 2021-01-30 04:32

I recently inherited a large software project written in Java. The last developer used Eclipse, so that\'s what I\'m using, but I can\'t figure out how to build anything. I don\

相关标签:
5条回答
  • 2021-01-30 04:59

    File -> Export -> Export JAR File. Then select your project, press next twice, select the main class.

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    If you just want to run, open the main class and click the green arrow at the top.

    enter image description here

    If you just want to build class files, I believe that Eclipse automatically builds every time you save. You need to select Project -> Build Automatically

    enter image description here

    0 讨论(0)
  • 2021-01-30 05:06

    you can check the file .project , this file tell eclipse how to build the project. if there are some code as follow:

    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
    

    mean , it's a java project. eclipse will auto build the project in a java project way. so it don't need another build script.

    0 讨论(0)
  • 2021-01-30 05:09

    normally eclipse build automatically as you add new files. try to clean the project first, maybe you will get an ungreyed build option.

    do you have java files in the project or just binaries.

    0 讨论(0)
  • 2021-01-30 05:09

    File > Import > Existing Project into Workspace.. to include the project into the workspace After that File -> Export -> Export JAR to export it to a jar file.

    0 讨论(0)
  • 2021-01-30 05:10

    Firstly, Eclipse is always building your project in the background. That doesn't help you much if what you want is a .jar file or web archive that you can deploy or execute. The suggestions about export to jar are correct if that's what you want.

    It's not clear how much Java experience you have, so I'll just ask this - are you sure there are no build scripts? Look for files called .pom, or a build.xml or .gradle files. If the project is as large as you say, I would have to imagine there is some sort of build script/descriptor, but if you're not familiar with Java build systems it may not be obvious to you.

    Eclipse (and just about any modern IDE) is a monstrously complex product, and any one or two line description we may give won't come close to getting you up and running on a large codebase. When you open the project up in eclipse are there red "X" icons on a ton of classes in the source tree? That's typical if you don't have your libraries all set up, which again, is a big topic. It would help to know if you imported a project someone already had up (or are just using their old development box) or if you're starting all this from scratch.

    0 讨论(0)
提交回复
热议问题