为何系统找不到java.mail.呢?

priamfang 2002-07-18 12:53:01
我在路径中添加了
D:\JBuilder7\jdk1.3.1\bin;D:\JBuilder7\jdk1.3.1\lib\dt.jar;D:\JBuilder7\jdk1.3.1\lib\tools.jar;D:\JBuilder7\jakarta-tomcat-3.3.1\lib\common\servlet.jar;d:\jbuilder7\lib\mail.jar;d:\jbuilder7\lib\activation.jar

运行环境:win2000,resin2.0.5.为何系统找不到java.mail.呢?

javamail.html
源程序如下

<html>
<head>
<title>发送邮件</title>
</head>
<body bgcolor=#add8e6>
<BR>
<HR>
<BR>
<center>
<h3>
现在你可以通过jsp页面向你的好朋友发送email了.请先在下面的
表格中,输入你的email信息,然后点击提交按钮,即可将你的邮件发送
到你朋友的信箱之中!
</h3>
<form name="email" action="sendMail.jsp" method="post" >
<table cellspacing="2" cellpadding="2" border="1">
<tr>
<td>收件人:</td>
<td><input type="text" name="to" size="30" maxlength="30"></td>
</tr>
<tr>
<td>发件人:</td>
<td><input type="text" name="from" size="30" maxlength="30" ></td>
</tr>
<tr>
<td>抄 送:</td>
<td><input type="text" name="cc" size="30" maxlength="100"></td>
</tr>
<tr>
<td>暗 送:</td>
<td><input type="text" name="bcc" size="30" maxlength="100"></td>
</tr>
<tr>
<td>主 题:</td>
<td><input type="text" name="subject" size="30" maxlength="30"></td>
</tr>
<tr>
<td colspan="2" align=center>
<textarea cols="40" rows="10" name="body" >...</textarea>
</td>
</tr>
<tr>
<td align=center colspan="2">
<input type="submit" name="submit" value="发送">
<input type="Reset">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
sendmail.jsp的源程序

<%@ page contentType="text/html;charset=gb2312" %>
<%@ page errorPage="errorPage.jsp" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.mail.*" %>
<%@ page import="javax.mail.internet.*" %>
<%@ page import="javax.activation.*" %>
<html>
<head>
<title>发送邮件</title>
</head bgcolor=#add8e6>
<body>
<center>
<font size=5 color=blue>发送邮件</font>
</center>
<BR>
<HR>
<BR>
<%
String host = "202.96.44.20";
String to = request.getParameter("to");
String from = request.getParameter("from");
String cc= request.getParameter("cc");
String bcc= request.getParameter("bcc");
byte[] subjectTemp= request.getParameter("subject").getBytes("ISO8859_1");
String subject=new String(subjectTemp);
byte[] messageTextTemp = request.getParameter("body").getBytes("ISO8859_1");
String messageText=new String(messageTextTemp);
boolean sessionDebug = false;
//validate the email address form.
if ((to.trim().indexOf("@")==-1)||(to.trim().length()<5)){
%>
<jsp:forward page="error.jsp"/>
<%}
if ((from.trim().indexOf("@")==-1)||(from.trim().length()<5)){
%>
<jsp:forward page="error.jsp"/>
<%}
if ((cc.trim().length()>0&&cc.trim().length()<5)||((cc.trim().length()!=0)&&(cc.trim().indexOf("@")==-1)))
{
%>
<jsp:forward page="error1.jsp"/>
<%
}
if ((bcc.trim().length()>0&&bcc.trim().length()<5)||((bcc.trim().length()!=0)&&(bcc.trim().indexOf("@")==-1)))
{
%>
<jsp:forward page="error1.jsp"/>
<%
}
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");
Session mailSession = Session.getDefaultInstance(props, null);
mailSession.setDebug(sessionDebug);
try{
Message msg = new MimeMessage(mailSession);
msg.setFrom(new InternetAddress(from));
InternetAddress[] addressTo = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO,addressTo);
if (cc.trim().length()!=0){
InternetAddress[] addressCc = {new InternetAddress(cc)};
msg.setRecipients(Message.RecipientType.CC,addressCc);
}
if (bcc.trim().length()!=0){
InternetAddress[] addressBcc = {new InternetAddress(bcc)};
msg.setRecipients(Message.RecipientType.BCC,addressBcc);
}
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);
Transport.send(msg);
}
catch(Exception ex){
out.println("sending failed");
}%>
<jsp:forward page="sendOk.jsp"/>
</table>
</body>
</html>

我在运行时系统报错:
Note: sun.tools.javac.Main has been deprecated. /sendMail.jsp:9: Package javax.mail not found in import. import javax.mail.*; ^ /sendMail.jsp:10: Package javax.mail.internet not found in import. import javax.mail.internet.*; ^ 2 errors, 1 warning
...全文
33 6 点赞 打赏 收藏 举报
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
priamfang 2002-07-18
解决,原因计算机没有重新启动
晕!!!!!!!!!
  • 打赏
  • 举报
回复
priamfang 2002-07-18
是单个的文件,以上的两个文件放在c:\resin-2,0,5\doc下
运行在http://localhost:8080/javamail.html
路经:
D:\JBuilder7\jdk1.3.1\bin;D:\JBuilder7\jdk1.3.1\lib\dt.jar;D:\JBuilder7\jdk1.3.1\lib\tools.jar;D:\JBuilder7\jakarta-tomcat-3.3.1\lib\common\servlet.jar;d:\jbuilder7\lib\mail.jar;d:\jbuilder7\lib\activation.jar;d:\jbuilder7\lib\pop3.jar
我在这里已经设了mail.jar。
运行中还是怎么还没有早mail呢?
  • 打赏
  • 举报
回复
trust_me 2002-07-18
你应该在classpath中,加入邮件包,如果你用的是servlet,你在编译java mail的时候,你就可以清楚的知道你没有加邮件包,至少应该包含:mail.jar;activation.jar;pop3.jar等
  • 打赏
  • 举报
回复
wes109 2002-07-18
不好意思resin没用过
  • 打赏
  • 举报
回复
priamfang 2002-07-18
怎么在resin-2.0.5中加邮件包,改配置文件吗???
我该怎么做?
  • 打赏
  • 举报
回复
GJA106 2002-07-18
resin2.0.5服务器中有没有加邮件包。
  • 打赏
  • 举报
回复
相关推荐
发帖
Java SE
创建于2007-09-28

6.2w+

社区成员

Java 2 Standard Edition
申请成为版主
帖子事件
创建了帖子
2002-07-18 12:53
社区公告
暂无公告