🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #17292

Re: How to include files?

#17292
From: Steve Horsley
Date: Thu, 26 Nov 1998 00:00
54 lines
2425 bytes
Each class should have its own source file, where the source file MUST
match 
the name of the class defined in it. 

The easiest thing to do when you are starting out is to put all the
sources
in the same directory. If you run the javac compiler on the main
appilcation
class, it will also compile any classes that the main app uses. 

E.g. if your main app is a class MyApp, and that application uses
classes Widget
and Thingy, you have a directory containing 3 files:
MyApp.java, Widget.java, Thingy.java.

Running javac on MyApp.java will compile that. It will also discover
that MyApp
uses Widget and Thingy, and compile them (if not already compiled).
This will leave you with 6 files:
MyApp.java, Widget.java, Thingy.java, MyApp.class, Widget.class,
Thingy.class.

Then running "java -cp . MyApp" will do the trick. MyApp can find and
bind
Widget and Thingy at run-time because they are in the classpath (.) you
gave.

The compiler seems a little strange about when it will/wont recompile
classes
whose sources have been updated, so I tend to do:
	del *.class
	javac MyApp.java
when I change any source. 
More experienced people will probably laugh at me for that. 

There is absolutely no equivalent to #include in java, but you don't
have to tie
all the sources together the way you do in C. The classpath for the
compiler
and run-time are all you need to tie the bits together.

I would leave making packages until you are more familiar with things.

Hope this helps.
Steve

Eric Advincula wrote:
> 
> When working on java code. I would like to separate the code into different
> fils ( toolbar.java and menu.java ). How would I be able to do that?  I'm
> coming from a C/C++ background so its clear when using header files and
> such.  Is the only way to do it is use packages?
> 
> Thanks
Technical Details
Message-ID: <365D44E7.71FE@cwcom.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <73hbnm$b7p11@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,de238e59aeee1894
X-Google-Attributes: gidf74b3,public
From: Steve Horsley <steve.horsley@cwcom.co.uk>
Subject: Re: How to include files?
Date: 1998/11/26
Message-ID: <365D44E7.71FE@cwcom.co.uk>
X-Deja-AN: 415866469
Content-Transfer-Encoding: 7bit
References: <73hbnm$b7p11@forums.borland.com>
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Reply-To: steve.horsley@cwcom.co.uk
Newsgroups: borland.public.jbuilder.java.language