1

I am taking a class in data structures, and they want us to use eclipse. Unfortunately, the intro programming class I took used jgrasp, so that's what I am used to. While I REALLY like the way that eclipse works, I can't seem to figure out how to download the support files for my assignments into my project so that they are usable. I have downloaded the support files, and put them into the same file as the class I am writing, but the downloaded files don't show up on eclipse, and when I try to implement the interfaces, they say that they don't exist. When I go through my computer, and look at the file with windows explorer, I can see all the files (both the ones that I downloaded and the ones that I wrote), but they don't show up in java, and when I try to use them, I get an error. I'm sure this is a really easy fix, but if ANYBODY could help me, I would be extremely grateful.

I have tried changing the build path, but I don't really understnad how to do that. The files I am trying to add are simple. One is an interface and the other is a special exception class that my professor developed.

user3562355
  • 131
  • 1
  • 7
  • 2
    Quick suggestion: Netbeans is much easier to use (and also much better imo). – Anubian Noob Apr 22 '14 at 22:52
  • Add the files separately into the buildpath (right-click the test.java -> BuildPath -> add to build path) – Sara S Apr 22 '14 at 22:53
  • Are you using any particular project layout (such as Maven) or is it a basic eclipse project? Try creating an empty project and from that point you can drag and drop .java files into the src directory. – cyber-monk Apr 22 '14 at 22:56
  • 1
    Do the support files (classes?) use any package? Have you placed them in directories based on the package names? When you say, "put them into the same file as the class I am writing", do you mean put them into the same directory (folder)? – David Conrad Apr 22 '14 at 22:59
  • possible duplicate of [How to import a jar in Eclipse](http://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse) – maxx777 Apr 22 '14 at 22:59
  • You could link a source folder. – Mingtao Zhang Apr 22 '14 at 23:08

1 Answers1

0

According to your title, you are using a .java file (not .jar, which is different) in Eclipse.

In that case, simply drag the .java file onto the Package Explorer pane in Eclipse and a popup should appear titled "File Operation" and ask how you want to import the files into Eclipse.

The options should be "Copy Files" and "Link to files". Select "Copy Files" since that is easiest.

After that, the Java code in the .java file becomes part of your project and the classes and interfaces defined in it can be called or implemented.

Hope that helps!

StanMarsh
  • 487
  • 1
  • 6
  • 16