
JAVABEANS FAQ: HELP WITH COMMON PROBLEMS
Why do
my event hookups fail to find
sun/tools/javac/Main?
You need to make sure that the JDK 1.1
version of the "java" command comes before any other version
of java on your PATH. The Java Development Kit (JDK) 1.1 includes the javac compiler
classes that are needed by the BeanBox. If you have
installed another JDK 1.1 tool (such as HotJava) that doesn't
include the compiler classes, then you must put it
after the JDK 1.1 bin directory on your PATH.
How do I
find out what version of JDK and the BDK I am
using?
Use "java -version" to check the version of
the JDK on your path. The output should be something like
java version "JDK 1.1_Final"
Starting with the February 1997 release of BDK 1.0, you
can check the version of your BeanBox by typing (on Windows
95 and Windows NT - for Solaris replace the "set" with the
appropriate "setenv"):
cd beanbox
set CLASSPATH=classes
java sun.beanbox.BeanBoxFrame -version
The output should be something like:
BeanBox version: BDK 1.0 - February 1997
When I try
to build the example Beans I get compiler errors. What's
wrong?
You need to use the JDK1.1 version of javac
to compile the BDK. If you use the JDK 1.0.2 compiler then
you will get errors when compiling various parts of the BDK
sources. See above for details on how to
find out what version you are using.
I'm
having trouble with the "Simplest Bean" from the February
'97 tutorial; what's the problem?
The original tutorial included in the
February '97 release of BDK had a few typographical errors,
particularly in the use of "/" and "\", and in some
instructions on how to run
nmake. There is a corrected
version of the tutorial, February '97 rev 3 that
can be downloaded from our web site in
Adobe's
PDF or
Postscript
formats.
Why do I
get a null pointer when loading a JAR file into the
BeanBox?
Usually this is because of a mistake in the
JAR file being loaded. The class loader used by the BeanBox
should give a better error message. This will be addressed
in a future release of the BDK. In the meantime, typical
errors include:
- The MANIFEST file uses classes using the wrong file
separator ("/" should be used in all platforms).
- The MANIFEST file refers to classes in a package but
the actual .class files are not really in that package.
Why do I
get a duplicate name error when loading a JAR
file
The most common reason for a
"java.lang.ClassFormatError: Duplicate name" error
is that a .class file in the JAR contains a class whose
class name is different from the expected name. So for example
if you have a file called "a/B.class" and it contains a class
called "B" or "a.X" instead of the class "a.B" then you will
get this error.
The most common causes for this problem are either forgetting
to include a "package a;" statement or having a "package" statement
with the wrong name.
Why does my Beans.instantiate() fail?
Beans.instantiate() does two things: it loads
a class and creates a Class object, and it then instantiates
an object of that class. If the Bean name corresponds to a
serialized Bean prototype, it uses that prototype. Otherwise
the instantiation uses a zero-argument constructor. Several
things may fail in these actions, including:
- There may not be a class of the given name
- The class may not be public
- The class may be in a package that cannot be created
given the existing Security Manager (for example, the
Applet Security Manager typically will not let the applet
instantiate "java.*" and "sun.*" classes)
- There may not be any public zero-argument constructor
for the class.
- The serialized stream may contain a version of the
class that is not compatible with the one loaded (or
available through the classloader argument) in the JVM.
A typical idiom to use Beans.instantiate is
Beans.instantiate(this.getClass().getClassLoader(),
theBeanName)
Why does
my BeanBox fail with a NullPointerException at start-up
time?
This is a bug in JDK 1.1 that affects a Java
application running JDK 1.1 under Solaris. It generally
appears when displaying against a remote X server. The bug
has been fixed in the upcoming JDK 1.1.1 maintenance
release.
From the bug description:
- You may get a NullPointerException if the default
font listed in the $JAVA_HOME/lib/font.properties file is
not available on Unix environments. In order to
workaround this, change the default font in this file to
a font which does exist on your system. If you don't need
to run in a multifont (internationalized) environment,
you can simply remove this file.
Where can I get a copy of nmake for Windows?
Nmake is available as a self-extracting .exe for download from: ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe
When I try to implement an event on another bean, I get the
statement "generating adapter class" and it hangs.
There is a bug in the BDK with the default installation in the "Program Files" directory.
The command that compiles the adapter class can't execute correctly because of the space in the path.
To fix it, you should re-install the BDK in a different location. Perhaps c:\bdk1.1.
This bug is discussed in the following bug report.
http://developer.java.sun.com/developer/bugParade/bugs/4257660.html
When I run the BeanBox under J2SE v 1.4 I get an exception. What's going on here?
There were some changes made to the Introspector in order for EventSets created by the
Intospector to conform to the JavaBeans specification. See bugs 4402159 and 4407239 for details. Unfortunately, the ExplicitButtonBeanInfo class
that shipped with the BDK do not conform to the JavaBeans specification and are rejected.
This is not as bad as it seems. Other than the exeption being thrown at startup and the failure to load
the buttons.jar file, the rest of the BeanBox will work fine.
As a work around, you may want to go into the sunw.demo.buttons.ExplicitBeanInfo.getEventSetDescriptors() source file, change the first actionPerformed string in the first EventSetDescriptor to be action
and recompile the class.
The source file for the demo beans used in the BeanBox is in
<BDK_INSTALL_DIR>demo\sunw\demo\buttons\ExplicitButtonBeanInfo.java.
At around line 47, change:
EventSetDescriptor push = new EventSetDescriptor(beanClass,
"actionPerformed",
java.awt.event.ActionListener.class,
"actionPerformed");
to:
EventSetDescriptor push = new EventSetDescriptor(beanClass,
"action",
java.awt.event.ActionListener.class,
"actionPerformed");