Adding .class files to an Eclipse project

34,238

Solution 1

You can place the class file anywhere, just be sure to add its directory to your project's build path. Right click on the project, then properties at the bottom then build path, til you find add class folder.

Solution 2

You have to create a project, or open your project if you have it already, then, while you are in the Java view, select File > New > File. It will open a window, you can create your file there and choose in which project folder do you want to put it. If in that window you press the button "Advanced >>" it will give you the option to "Link to file in the system", check it, and then you can browse your folders to the downloaded file.

I don't know if this solves your problem, it's what I understood from your question.

Solution 3

Your instructors class file must be in the build-time and the run-time class paths for your project to use it. Instructions assume that you are on a PC.

Run-time class path setup

  1. Create a directory (perhaps C:\JavaRoot\classes). I will refer to this as the Classes directory.
  2. If one does not already exist on your PC, create an environment variable named CLASSPATH
  3. Add the Classes directory to your CLASSPATH envoronment variable
  4. Download the class in question and put it in the Classes directory.

Build-time class path setup

  1. Right mouse on your project in eclipse.
  2. Select "Properties".
  3. Select "Java Build Path".
  4. Select the "Libraries" tab.
  5. Click the "Add a Class Folder" button.
  6. Browse to and select the Classes directory you created during "Run-time class path setup" above.
  7. Click the "OK" button

Solution 4

For Eclipse use the following:
Project > Properties > Java Build Path > Libraries (Tab) > Add External Class Folder (Button)

Share:
34,238
Admin
Author by

Admin

Updated on March 23, 2020

Comments

  • Admin
    Admin about 4 years

    This is a total newbie question, but I can't figure it out so I figured that I would ask it here and see what happened.

    Here's the problem: For my java programming class, we are supposed to download a .class file created by our instructors containing a custom-made class with methods that we are supposed to use in an assignment. I already know all of the code to create the class within my actual program, but I can't figure out which directory to place the .class file in. I have tried the src and bin folders inside the project directory, and even placed it directly into the project directory, but nothing seems to work. My instructors say to just put it in the same directory as my java program, but they are using jGRASP. What am I doing wrong?

  • Hovercraft Full Of Eels
    Hovercraft Full Of Eels over 13 years
    but having said that. you must be sure that the class files are in a proper package directory structure. Better to add the external library as a jar file, I suppose.