简体   繁体   中英

How to import src project in eclipse

So I am working on a java project that requires me to analyze the Dijkstra and Bellman Ford algorithms by running time.

Now I am trying to write my collected data to an xls or xlsx file. I have found the Apache POI: http://poi.apache.org/download.html#POI-3.10-beta2 which will help me do that.

My only issue is that I'm having trouble adding the source to my existing project to use. Apache POI comes as a src folder. Dragging and dropping the folder into eclipse adds the files but the packages aren't right.

For example, in one of the java files the package is declared as:

package org.apache.poi.hpsf.examples;

But when dragged into eclipse the package becomes examples.src.org.apache.poi.hpsf.examples... This causes eclipse to throw the "The declared package "org.apache.poi.hpsf.examples" does not match the expected package "examples.src.org.apache.poi.hpsf.examples"

Now I could simply move this package to the right folder but there are dozens of packages with this same problem?

How would I properly add these files to eclipse so I could use them?

I would write to CSV then import the CSV to Excel, unless there's a compelling reason specifically for using Excel. The benefits of this are:

  1. No need for extra libraries.
  2. You can open the file in other things (emacs, load into R to draw graphs).

If you really just want to use POI, the thing to do is download the JAR file, go to Options > Properties > Build Path > Libraries > Add JARs and then select the jar. (You should see a dialog like this .)

Right click on the project name -> Properties -> Java Build Path and on the the source tab, select the examples/src dir.

BUT, if I correctly understood the problem, you want to use the POI library, so in that case get a jar version of it, and then right click on the project name -> Properties -> Java Build Path and on the the libraries tab, select the location of the jar file.

This way, you can write your own java classes and import the POI library into your project.

Try the File menu, then select Import, then expand General, then "Existing Projects into Workspace". You will have the option of whether or not to create a new copy of the whole directory in your workspace directory as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM