Java 如何执行我的程序?

Java 如何执行我的程序?,java,html,eclipse,Java,Html,Eclipse,下面是我的程序代码。我想从linux服务器复制一个html文件,并将该html文件作为电子邮件正文发送。我正在使用类路径导入我的jar文件并成功完成编译,但在运行程序时出错。下面是从Linux服务器执行时的错误。 从Eclipse运行时也会出现错误 import java.io.*; import java.util.*; //import java.sql.*; import javax.mail.*; import javax.mail.internet.*; public class Se

下面是我的程序代码。我想从linux服务器复制一个html文件,并将该html文件作为电子邮件正文发送。我正在使用类路径导入我的jar文件并成功完成编译,但在运行程序时出错。下面是从Linux服务器执行时的错误。 从Eclipse运行时也会出现错误

import java.io.*;
import java.util.*;
//import java.sql.*;
import javax.mail.*;
import javax.mail.internet.*;
public class SendTable1 {

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception, IOException{
            try {
                    String host = "127.0.0.1";
                    String from = "ychilukuri@zetainteractive.com";
                    String to = "supalerts@zetainteractive.com";
                    Properties properties = System.getProperties();
                    properties.setProperty("mail.smtp.host",host);
                    Session session = Session.getDefaultInstance(properties);
                    MimeMessage message = new MimeMessage(session);
                    message.setFrom(new InternetAddress(from));
                    message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
                    message.setSubject("DataBase table");
                    FileInputStream fst = new FileInputStream("abuses.html");
            int cnt = 0;
                    StringBuffer buffer = new StringBuffer();
                    while ((cnt = fst.read()) != -1 )
                {
                       buffer.append((char) cnt);
                    }
                    message.setText("" +buffer.toString() ,"text/plain");
                    Transport.send(message);
                    System.out.println("message send......");
            }
            catch(Exception ex)  {
            ex.printStackTrace();
            System.out.println("Error :" +ex.getMessage());
            }
        }
    }
汇编:

javac -classpath /home/ebiz40/product/6.1.0/zemo/webapps/zetamobile/WEB-INF/lib/mail.jar /home/ebiz40/SendTable1.java


~]$ java -classpath /home/ebiz40/product/6.1.0/zemo/webapps/zetamobile/WEB-INF/lib/mail.jar /home/ebiz40/SendTable1
Error: Could not find or load main class .home.ebiz40.SendTable1
~]$ java -classpath .:. /home/ebiz40/product/6.1.0/zemo/webapps/zetamobile/WEB-INF/lib/mail.jar  /home/ebiz40/SendTable1
Error: Could not find or load main class .home.ebiz40.product.6.1.0.zemo.webapps.zetamobile.WEB-INF.lib.mail.jar
~]$ java -classpath .  /home/ebiz40/product/6.1.0/zemo/webapps/zetamobile/WEB-INF/lib/mail.jar  /home/ebiz40/SendTable1
Error: Could not find or load main class .home.ebiz40.product.6.1.0.zemo.webapps.zetamobile.WEB-INF.lib.mail.jar
下面是来自Eclipse的错误:

javax.mail.MessagingException: Could not connect to SMTP host: 127.0.0.1, port: 25;
  nested exception is:
      java.net.ConnectException: Connection refused: connectError :Could not connect to SMTP host: 127.0.0.1, port: 25

      at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1706)
      at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:525)
      at javax.mail.Service.connect(Service.java:291)
      at javax.mail.Service.connect(Service.java:172)
      at javax.mail.Service.connect(Service.java:121)
      at javax.mail.Transport.send0(Transport.java:190)
      at javax.mail.Transport.send(Transport.java:120)

请让我们知道我哪里出错了?如何解决此问题?

您是否在计算机中设置了邮件服务器?eclipse错误是它无法连接到本地计算机中的邮件服务器。您有SMTP服务器设置吗?您的计算机中没有配置邮件服务器。本地主机服务器(127.0.0.1)必须为此打开。下面是以前线程中可能有用的一些信息