Subject: RE: Java Class Library - Much Simpler Explanation
He suggests that it is okay to have spaces in the name of your Java library as he demonstrates with his “Unused Java GUI Testing” example which is incorrect.
Why do you think it’s incorrect to have spaces in the name of a Java library? It works just fine.
He also tells you that you have to do some kind of importing of each class you need to use. Maybe that has worked for him, but I find this suggestion to be too complicated if you ask me.
What I actually wrote is that you can package classes within a Java Library. Packaging is a good idea for Java code whether it’s written in Notes or anywhere else. It helps to organize the code and, when done properly, can help protect it from being accessed inappropriately by other code. There are tons of respected individuals and companies (including Sun) that “suggest” packaging. As you observed, you don’t necessarily have to package your code, but then again you don’t have to use “Option Declare” in LotusScript either – even though it’s a recognized best practice.
So, if you agree with the rest of us that organizing your Java source code by packaging it is a good idea, then you have two ways to use packaged code once it’s in your classpath:
by the qualified class name – for example:
public class MyClass {
org.apache.log4j.Logger logger = org.apache.log4j.Logger.getRootLogger()
public MyClass() {
}
public void logText(String pstrText) {
this.logger.info(pstrText);
}
}
or by importing the class – for example:
import org.apache.log4j.Logger;
public class MyClass {
Logger logger = Logger.getRootLogger()
public MyClass() {
}
public void logText(String pstrText) {
this.logger.info(pstrText);
}
}
If that’s “too complicated” for you, do it your way – don’t use packaging. But there are a lot of knowledgeable people who would advise you otherwise.
dgg