Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » need help using a textbook class file in Eclipse
need help using a textbook class file in Eclipse [message #201986] Wed, 28 March 2007 13:05 Go to next message
Eclipse UserFriend
Originally posted by: jdelvecchio.rhnet.org

Hello-

I'm a new java programmer (and teaching it to high schoolers). The text we
are using supplies us with a Keyboard.class file to use in the
introductory programs. I have the class file on my hard drive. I can't
get my code to work in Eclipse because it is looking for the cs1.Keyboard
class and can't find it.

I've read some info at this site on importing class files, but those
techniques haven't worked for me.

My question, how can I have an Eclipse project find the Keyboard class
when I type in the following at the beginning of the code:
import cs1.Keyboard

Thanks!

-Jon
Re: need help using a textbook class file in Eclipse [message #202064 is a reply to message #201986] Wed, 28 March 2007 17:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse5.rizzoweb.com

Jon D. wrote:
> Hello-
>
> I'm a new java programmer (and teaching it to high schoolers). The text
> we are using supplies us with a Keyboard.class file to use in the
> introductory programs. I have the class file on my hard drive. I can't
> get my code to work in Eclipse because it is looking for the
> cs1.Keyboard class and can't find it.
>
> I've read some info at this site on importing class files, but those
> techniques haven't worked for me.
>
> My question, how can I have an Eclipse project find the Keyboard class
> when I type in the following at the beginning of the code:
> import cs1.Keyboard

You need to copy the .class file into your Eclipse Project; put it in a
directory under your Project named /lib/classes (or any name you choose).
Is the Keyboard class in a package? If so, you must put it in a
directory structure that mirrors the package names. For example, if
Keyboard is in a package named com.foo, then you'll need it in a
directory of your project like this:
MyProject/
lib/
classes/
com/
foo/
Keyboard.class

If Keyboard class has no package (it is in the "default" pacakge) then
you don't need the com/foo/ container, just put it in classes/ directly.

Then open the Properties for your Project, select the Java Build Path
section and then the Libraries tab. There you can click the Add class
folder... button to include the lib/classes directory you added above.

By the way, the tutorials might help you understand Eclipse better. Open
the Eclipse Help Contents and navigate to Java Developer User Guide,
Getting Started and you'll find some tutorials.

Hope this helps,
Eric
Re: need help using a textbook class file in Eclipse [message #202196 is a reply to message #202064] Thu, 29 March 2007 12:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jdelvecchio.rhnet.org

Jon D. wrote:

Hello-

I'm a new java programmer (and teaching it to high schoolers). The text we
are using supplies us with a Keyboard.class file to use in the
introductory programs. I have the class file on my hard drive. I can't
get my code to work in Eclipse because it is looking for the cs1.Keyboard
class and can't find it.

I've read some info at this site on importing class files, but those
techniques haven't worked for me.

My question, how can I have an Eclipse project find the Keyboard class
when I type in the following at the beginning of the code:
import cs1.Keyboard


You need to copy the .class file into your Eclipse Project; put it in a
directory under your Project named /lib/classes (or any name you choose).
Is the Keyboard class in a package? If so, you must put it in a directory
structure that mirrors the package names. For example, if Keyboard is in a
package named com.foo, then you'll need it in a directory of your project
like this:
MyProject/
lib/
classes/
com/
foo/
Keyboard.class

If Keyboard class has no package (it is in the "default" pacakge) then you
don't need the com/foo/ container, just put it in classes/ directly.

Then open the Properties for your Project, select the Java Build Path
section and then the Libraries tab. There you can click the Add class
folder... button to include the lib/classes directory you added above.

By the way, the tutorials might help you understand Eclipse better. Open
the Eclipse Help Contents and navigate to Java Developer User Guide,
Getting Started and you'll find some tutorials.

Hope this helps,
Eric

**************
Thanks Eric. Follow up questions:

"...put it in a directory under your Project named /lib/classes (or any
name you choose)." Right now the Keyboard.class file is on the c: drive
in folder cs1 I can't put any files under Program Files due to security.
In Eclipse, under my project is a directory "JRE System Library
[jre1.5.0_06]" Underneath there are paths to a directory which ends with
lib, is that what you are referring to? Sorry to be so stupid. How/where
do I put it?
Re: need help using a textbook class file in Eclipse [message #202208 is a reply to message #202196] Thu, 29 March 2007 13:25 Go to previous message
Eclipse UserFriend
Originally posted by: eclipse5.rizzoweb.com

Jon D. wrote:
> "...put it in a directory under your Project named /lib/classes (or any
> name you choose)." Right now the Keyboard.class file is on the c: drive
> in folder cs1 I can't put any files under Program Files due to
> security. In Eclipse, under my project is a directory "JRE System
> Library [jre1.5.0_06]" Underneath there are paths to a directory which
> ends with lib, is that what you are referring to? Sorry to be so
> stupid. How/where do I put it?
>

I don't know what your project already contains, so I can't be sure. It
sounds like you might have a lib/ directory in the project already. If
so, you can create lib/classes/cs1/ and put Keyboard.class in there.
Then you'll need to add lib/classes/ to the Java Build Path as I said
before.
Also note that you are using the Java Perspective (the panel you
describe is the Package Explorer). You might find it easier to open the
Resource perspective and use the Navigator view (GUI panels are called
Views in Eclipse) to move files around. Package Explorer is a "filtered"
view of the file system, while Navigator is more like Windows File Explorer.

I recommend again doing the Help tutorials under Workbench and Java user
guides. The information you'll learn is invaluable and will save you
some frustration.

Hope this helps,
Eric
Previous Topic:Help with Help "Loading... please wait"
Next Topic:Viewing Environment Variables within Eclipse
Goto Forum:
  


Current Time: Thu Mar 28 21:48:11 GMT 2024

Powered by FUDForum. Page generated in 0.04165 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top