关于java下的import

lxg2000 2002-10-16 05:19:29
我的java文件如下(部分代码)
import java.lang.*;
import java.lang.reflect.*;
import java.io.*;
import java.util.Properties;
import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;
import java.util.StringTokenizer;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import org.w3c.dom.*;

public class ShWbdt implements ApConstant{
//クラス変数


static private ShWbdt instance; // The single instance

//インスタンス変数
private String propFilePath; //項目属性ファイルへのパス
private String fileEncode; //エンコード情報
private Hashtable itemProperty; //項目属性情報ドキュメント

/**
* Returns the single instance, creating one if it's the
* first time this method is called.
*
* @return CmWbdt The single instance.
*/
//プロパティファイル指定なし
static synchronized public ShWbdt getInstance() {
if (instance == null) {
instance = new ShWbdt();
}
return instance;
}
//プロパティファイル指定あり
static synchronized public ShWbdt getInstance(String enctype) {
if (instance == null) {
instance = new ShWbdt(enctype);
}
return instance;
}

/**
* A private constructor since this is a Singleton
*/
private ShWbdt() { //指定なし
init();
}
private ShWbdt(String enctype) { //指定あり
init(enctype);
}

/**
* 初期化処理
*/
private void init() { //指定なし
fileEncode = C_DEFAULT_ENCODE;
itemProperty = new Hashtable();
}
private void init(String enctype) {
if(enctype!=null)
fileEncode = enctype;
else
fileEncode = C_DEFAULT_ENCODE;

itemProperty = new Hashtable();
}

/**
* DOMオブジェクト生成
*
* @param path 項目属性ファイル配置パス
* @param gamenid 画面ID
* @return 読み込み完了:true , エラー:false
*/
public synchronized boolean prepareItemProperty( String path,String gamenid )
{

if( itemProperty.get(gamenid)!=null )
{
notifyAll();
return true;

}

DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();

dbf.setValidating(false);
dbf.setIgnoringComments(false);
dbf.setIgnoringElementContentWhitespace(false);
dbf.setCoalescing(false);
dbf.setExpandEntityReferences(false);

DocumentBuilder db = null;
notifyAll();
return true;
}
}
当我用tomcat运行时抛出异常
我屏蔽public synchronized boolean prepareItemProperty( String path,String gamenid )是函数正常运行
但我没有调用prepareItemProperty()函数
只要prepareItemProperty()函数中定义了
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import org.w3c.dom.*;
其中任何一个方法函数就会抛出异常
为何原因
我的系统是win2000server tomcat 4.0
...全文
63 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
merciful 2002-10-17
  • 打赏
  • 举报
回复
tomcat的版本不对,应该改用tomcat3.3a则可以解决这个问题
beming 2002-10-17
  • 打赏
  • 举报
回复
应该系日本XX写的吧^_^

我想原因有:有可能是你的claspath没有设置好,或者你的class路径不对,再不程序错误,try{}catch{}没有使用有时也会抛出异常的
hello_wyq 2002-10-17
  • 打赏
  • 举报
回复
好像程序是个鬼子编写的吧?


forjie 2002-10-16
  • 打赏
  • 举报
回复
notifyall()会产生interruptedException异常,把它用try/catch包起来就可以了。

public synchronized boolean prepareItemProperty( String path,String gamenid )
{

if( itemProperty.get(gamenid)!=null )
{
try {
notifyAll();
}
catch (InterruptedException e) {
return false;
}
return true;

}
yangtian 2002-10-16
  • 打赏
  • 举报
回复
关注!
haode 2002-10-16
  • 打赏
  • 举报
回复
你看一下,有些方法就是要抛出异常的

你要try,catch一把
DanielYWoo 2002-10-16
  • 打赏
  • 举报
回复
classpath
wjmmml 2002-10-16
  • 打赏
  • 举报
回复
是啊,你要对可能抛出的异常进行处理啊。用
try{}catch(){}
zfluo 2002-10-16
  • 打赏
  • 举报
回复
估计是你的classpath没有设置好

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧