JDK-4031334 : Program does not exit if awt.properties is loaded without a container
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95
  • CPU: x86
  • Submitted: 1997-02-10
  • Updated: 2001-06-27
  • Resolved: 2001-06-27
Related Reports
Duplicate :  
Description

Name: mc57594			Date: 02/10/97


Below is a simple program. It takes one argument, but in this
revision the argument is ignored. It shows that if you create
an instance of an AWT subclass by itself, the program does not
exit completely. Ctrl-C must be used to stop it. This seems
to occur when making the new instance causes the message:
'Loading d:\JDK\JAVA\bin\..\lib\awt.properties'.
I came across
this problem while doing some beans stuff. I wish to instantiate
a bean. The Java Beans docs on page 88 say you simply use the
new constructor, which is what I am trying to do.

My real problem may be worse. It is intended that the argument
passed to this program will be a class name. I must convert
this class name dynamically to a class and create an instance of that
bean. In this case, I can not use the new constructor. Is
using newInstance() the recommended way?

-----
Case 1. Simply use the new constructor
----
package TestBeanReader;
import sun.demo.buttons.*;

	public class BeanProblem {

    public static void main(String args[]) {
	BeanProblem	beanProblem = new BeanProblem();

	beanProblem.start(args[0]);
    }
   
   public String start(String beanClassName) {
	OurButton ob = null;
	
	ob = new OurButton();	
	return "ok";
    }
   
}

---------
Case 2- Use the argument to make an instance. Only changing the start() method.
The argument has a ".class" extension.
This will probably be solved in the same way as Case 1.
-------
   public String start(String beanClassName) {
	Class beanClass = null;
	Object bean;
	
	try { beanClass = Class.forName(beanClassName.substring(0,beanClassName.length()-6)); }
	       catch (Exception ex) {System.out.println("Class not found"); return null;}
	if(beanClass == null) {System.out.println("The class was not found"); return null;}
	   try {bean = beanClass.newInstance();}
	       catch (Exception ex) {System.out.println("Can't make new instance"); return null;}
	return "ok";
    }

company  -  Objectshare   , email  -  ###@###.###
======================================================================

Comments
WORK AROUND Name: mc57594 Date: 02/10/97 ======================================================================
11-06-2004

EVALUATION Probably a dupe of 4030718. eric.hawkes@eng 2000-05-04
04-05-2000