Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Beginner's question: How to import a class. 1

Status
Not open for further replies.

SH4F33

Programmer
Apr 1, 2005
58
MU
Hello there.Im very new to java programming and maybe wat Im going to ask is very simple. Anyways. Ive just started with java and im using borland jbuilder 2005 as my ide. Ive created a project "bank" whick is in a folder called bank. And my package name's also bank. Ive got a class called Account.class which is in the bank folder.
And Ive created another project in another folder. And I want to import the Account.class to the new project. I tried typing import Account.*; or import bank.Account.*; but I dont c the Account in the popup menu.
In the java(sun) forum,someone told me I must let the ide know where to look for that Account.class, but I dont know how to do that.
Can anyone help?
Thanks.
 
I usually get JBuilder to create me a 'jar' file containing the classes I need to use elsewhere. This jar can then be used as a 'library' in other JBuilder projects, which will then be able to 'see' the classes it contains.

I'm using JBuilder X, so the following may be slightly different in JBuilder 2005 :-

Create a jar in your first project using the File->New to get the Object Gallery, then select the 'build' page and 'Archive Builder'. You need to give it a name and location for the archive (jar), but the rest of the defaults should get you a jar containing all of the project's classes. Rebuild the project and check the jar has been created.

In the project which needs to see the classes, go to Tools->Configure Libraries. Select New, choose a name for your library entry and select 'Project' as the location. Click the 'Add' button and browse for your newly built jar file. Click OK and then go to Project->Project Properties. In the 'Required Libraries' tab, click 'Add' and select your library entry. This project should then be able to see all the class in the associated jar file. Just remember to 'import' them at the top of the relevant classes.


Tim
---------------------------
"Your morbid fear of losing,
destroys the lives you're using." - Ozzy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top