很小很小的JAVA问题,注释已写好,希望能帮助你们帮我解答

来源:百度知道 编辑:UC知道 时间:2024/06/08 06:09:14
import java.util.*;
import javax.naming.*;
import javax.jms.*;
import javax.jms.Queue;

public class QueueSender{
//连接工厂
private QueueConnectionFactory factory = null;
//连接
private QueueConnection connection = null;
//会话
private QueueSession session = null;
//目的地
private Queue queue = null;
//发送者
private QueueSender sender = null;
//消息
private TextMessage message = null;
public Context InitialContext(){
Context context= null;
try {
Properties properties = new Properties();
properties.put(context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
properties.put(context.PROVIDER_URL,"t3://127.0.0.1:7001");
context = new InitialContext(properties);
}
catch (Exception ex) {
ex.printStackTrace();
}
return context;
}
public void send(){
try {

忍了,你定义的类名和import javax.jms.QueueSender的类名一样,他当然是先找本类了

把import javax.jms.Queue;
改成import javax.jms.QueueSender;

这是我从逻辑上判断的,说实话.我学这么久java还没见过javax里有jms呢,不是JDK里的吧?