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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Packaging howto? 2

Status
Not open for further replies.

iSeriesCodePoet

Programmer
Jan 11, 2001
1,373
US
I am writing some classes that I will be making available through my website. I want to make sure that there are no problems and throw the proper exceptions and such. How is that done? Also, how do I seperate out source vs. binary?

Also, how do I make a javadoc? I have the proper format for the comments in the code. How do I execute the program? Just use 'javadoc MyClass.java'? Mike Wills
AS400 Programmer
[pc2]

Please, if you find my post useful, let me know. [thumbsup2]
 
Hi Mike,

most of the documentation for that can be had at the prompt. On my computer, that's

C:\jdk1.3.1_01\bin\javac (see especially the -d option)
C:\jdk1.3.1_01\bin\javadoc

For distribution, you also might want to jar it (one single archive)
C:\jdk1.3.1_01\bin\jar

to have the classes be in the same package, you have to declare it as the first thing at the top of the file, something like

package com.MikeWills.MyPackage;

that has an impact on where you put it on your computer... that is the files will be in something like:

c:\myproject\source\com\MikeWills\MyPackage
you might have an easier time if you send your commands from c:\myproject\, e.g.; otherwise I can have a hard time, especially with javadoc.

set myroot=c:\myproject
set DEST=%myroot%\release
set SOURCE=%myroot%\source\com\MikeWills\MyPackage
c:\myproject>C:\jdk1.3.1_01\bin\javac -classpath %MYCLASSPATH% -d %DEST% %SOURCE%\*.java

(you'll also need to set your classpath)

good luck, and please tell us when you release your files!
 
Is there some sort of website that has good documentation on this? Your information should help me. Thanks.

How do I best handle the errors that a user could pass in? Like I have a class that deals with dates. How would I prevent a user from passing an invalid date (I haven't looked closely enough to the Date API yet)? Throw my own exceptions? If so how is that done? Mike Wills
AS400 Programmer
[pc2]

Please, if you find my post useful, let me know. [thumbsup2]
 
Figuring out where and what exceptions to throw can take a bit of practice. All Java Exceptions have a String message, so I actually have simply used the following construct:

if (input == null) throw new Exception("My error message");

You can use a more appropriate exception for your case... browse the JDK to find an exception that is suited to your specific task. You could also extend the Exception class:

class MyException extends Exception {}

HTH
 
Thanks, that will help alot! Mike Wills
AS400 Programmer
[pc2]

Please, if you find my post useful, let me know. [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top