Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

I want to use a java class I created - where to put file / code?

Thread view: 
Angus - 26 Nov 2006 21:13 GMT
Hello

I have created a java class which I want to use from another java program.

Do I need to store the java file in a particular location?  (bit like C/C++
include files?).

I tried just pasting class to bottom of file with main java program I was
using but that didn't work.  Can I just have class in same file?  But how?

Any help would be much appreciated.

Angus
Arne Vajhøj - 26 Nov 2006 22:15 GMT
> I have created a java class which I want to use from another java program.
>
[quoted text clipped - 5 lines]
>
> Any help would be much appreciated.

You can only have one public class per source file.

I think what you are looking for is "classpath".

Simple example:

javac -classpath .;C:\utilities Foobar.java
java -classpath .;C:\utilities Foobar

will be able to use a class mystuff.SmartUtility
in C:\utilities\mystuff\SmartUtility.class

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.