I'm just learning (or trying) Java Beans. I've been going through the Sun tutorial, as well I have several books, but I can't get the SimpleBean to work from the tutorial. First, I had troubles even getting BeanBox to work properly. The buttons.jar had a problem, and I had to remove one of the classes to get it to work. Now, I've done the SimpleBeans from sun tutorial verbatim, and when I try to load the jar, it says the jar contains no beans. My manifest file is as follows: Name: tutorial/SimpleBean.class Java-Bean: True When I perform jar tf simplebean.jar to get contents, results are: META-INF/ META-INF/MANIFEST.MF SimpleBean.class Message from BeanBox is: jar file c:\tutorial\simplebean.jar didn't have any beans! Am I missing something basic here?
Two things. First, the manifest says that the class name is tutorial.SimpleBean, but in the JAR file it's stored as if it were just SimpleBean, in the default package. You need to get these two straight. I don't know which is correct in this particular case -- it depends on whether SimpleBean.java contains a "package tutorial" statement or not. Don't use a slash to separate the package components -- use a dot, like tutorial.SimpleBean . Second, don't use the ".class" extension in the manifest file. The entries name classes, not files, so you're making it look as if there's a class named "class" in the package "tutorial.SimpleBean". That should fix the problem.
I have the BeanBox installed, so I cut-and-pasted your files and command lines and tried them out, and then used the LoadJar menu command to load up the JAR file, and it worked. I was able to create and use a SimpleBean! So I'm at a loss, really; sorry I can't think of anything else.
Thanks for the help... maybe it's my computer. I'll boot up my other pc and get it installed on there and try it out. This is the kind of thing I find frustrating about Java, there seems to be some ambiguous problems with it, maybe due to the open-source nature of Java? I like the language, and the robustness (is that a word) of it, but I seem to run into many roadblocks on some of the things that should be simple (although, by the time I get past the road block, I feel like I've really learned something). Anyway, I digress.
posted 15 years ago
Okay, I figured it out. I used winrar to go into the jar file and investigate my manifest file. The line Java-Bean: True was missing, so I checked my original manifest, and it was there... odd. I then went back through the API spec and tutorial, and found the missing piece of info... must have a blank line at the end of the manifest file. Guess that's why I'm a Greenhorn. Anyway, it works now. Thanks.
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
how do I do my own kindle-like thing - without amazon