Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 1110|回复: 6
打印 上一主题 下一主题

帮帮忙.....java 的问题

[复制链接]

203

主题

0

好友

2800

积分

认证卖家

Rank: 50Rank: 50Rank: 50Rank: 50Rank: 50

跳转到指定楼层
1#
发表于 2009-6-26 02:17 AM |只看该作者 |倒序浏览
--------------------Configuration: <Default>--------------------
java.lang.NoSuchMethodError: main
Exception in thread "main"
Process completed.

请问为什么会这样呢?
build file是没有问题
但是 run project 就是出现这样的东西了

[ 本帖最后由 理想の情人 于 2009-6-26 02:30 AM 编辑 ]




收藏收藏0

203

主题

0

好友

2800

积分

认证卖家

Rank: 50Rank: 50Rank: 50Rank: 50Rank: 50

2#
发表于 2009-6-26 02:36 AM |只看该作者
CODE 如下:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.io.*;
import java.security.*;
import java.lang.*;
import java.math.*;
import java.util.*;
import java.security.spec.*;


   
public class DSA extends java.applet.Applet {


        // member declarations
        java.awt.Label lblIput = new java.awt.Label();
        java.awt.TextField InputTxt = new java.awt.TextField();
        java.awt.Button cmdsign = new java.awt.Button();
        java.awt.TextField Rtxt = new java.awt.TextField();
        java.awt.Button Cmdverify = new java.awt.Button();
        java.awt.Button cmdhash = new java.awt.Button();
        java.awt.TextField textField2 = new java.awt.TextField();
        java.awt.TextField textField1 = new java.awt.TextField();
        java.awt.TextField textField3 = new java.awt.TextField();
        java.awt.Label lbhash = new java.awt.Label();
        java.awt.Label lbS = new java.awt.Label();
        java.awt.Label lby = new java.awt.Label();
        java.awt.Label label2 = new java.awt.Label();
        java.awt.Label lbverify = new java.awt.Label();
        java.awt.Button cmdReset = new java.awt.Button();
        BigInteger p,q,g,x,y,k,K,X,Y,R,S,hshm,P,Q,G;
         int xcmp,kcmp;
         String m;       


String p1 = ("fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7");
        
String q1 = ("9760508f15230b[词语过滤-#261]292b982a2eb840bf0581cf5");
       
String g1 = ("f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a");

       
       
       
       
// END GENERATED CODE

        boolean isStandalone = false;

        public DSA() {initComponents();
        }

        // Retrieve the value of an applet parameter
        public String getParameter(String key, String def) {
                return isStandalone ? System.getProperty(key, def) :
                        (getParameter(key) != null ? getParameter(key) : def);
        }

        // Get info on the applet parameters
        public String[][] getParameterInfo() {
                return null;
        }

        // Get applet information
        public String getAppletInfo() {
                return "Applet Information";
        }

        // Initialize the applet
        public void init() {
                try {
                        initComponents();
                }
                catch (Exception e) {
                        e.printStackTrace();
                }
        }

        public void initComponents()  {

                // the following code sets the frame's initial state
                lblIput.setFont(new java.awt.Font("Dialog", 0, 14));
                lblIput.setVisible(true);
                lblIput.setLocation(new java.awt.Point(30, 30));
                lblIput.setText("INPUT MESSAGE");
                lblIput.setSize(new java.awt.Dimension(130, 40));
                InputTxt.setLocation(new java.awt.Point(200, 10));
                InputTxt.setVisible(true);
                InputTxt.setSize(new java.awt.Dimension(250, 100));
                cmdsign.setVisible(true);
                cmdsign.setLabel("SIGN");
                cmdsign.setLocation(new java.awt.Point(240, 260));
                cmdsign.setSize(new java.awt.Dimension(120, 40));
                Rtxt.setLocation(new java.awt.Point(20, 360));
                Rtxt.setVisible(true);
                Rtxt.setSize(new java.awt.Dimension(620, 40));
                Cmdverify.setVisible(true);
                Cmdverify.setLabel("VERIFY");
                Cmdverify.setLocation(new java.awt.Point(290, 630));
                Cmdverify.setSize(new java.awt.Dimension(120, 40));
                cmdhash.setVisible(true);
                cmdhash.setLabel("HASH");
                cmdhash.setLocation(new java.awt.Point(240, 120));
                cmdhash.setSize(new java.awt.Dimension(120, 40));
                textField2.setLocation(new java.awt.Point(20, 460));
                textField2.setVisible(true);
                textField2.setSize(new java.awt.Dimension(620, 40));
                textField1.setLocation(new java.awt.Point(20, 570));
                textField1.setVisible(true);
                textField1.setSize(new java.awt.Dimension(620, 40));
                textField3.setLocation(new java.awt.Point(20, 210));
                textField3.setVisible(true);
                textField3.setSize(new java.awt.Dimension(620, 40));
                lbhash.setVisible(true);
                lbhash.setLocation(new java.awt.Point(30, 170));
                lbhash.setText("The Message after Hsahing is:");
                lbhash.setSize(new java.awt.Dimension(300, 30));
                lbS.setVisible(true);
                lbS.setLocation(new java.awt.Point(20, 420));
                lbS.setText("The value of  s   is :");
                lbS.setSize(new java.awt.Dimension(300, 30));
                lby.setVisible(true);
                lby.setLocation(new java.awt.Point(20, 520));
                lby.setText("The value of  y   is :");
                lby.setSize(new java.awt.Dimension(300, 40));
                label2.setVisible(true);
                label2.setLocation(new java.awt.Point(20, 320));
                label2.setText("The value of  r  is :");
                label2.setSize(new java.awt.Dimension(300, 30));
                lbverify.setVisible(true);
                lbverify.setLocation(new java.awt.Point(50, 680));
                lbverify.setText("TO BE VERIFIED ");
                lbverify.setSize(new java.awt.Dimension(570, 50));
                cmdReset.setVisible(true);
                cmdReset.setLabel("Reset");
                cmdReset.setLocation(new java.awt.Point(290, 750));
                cmdReset.setSize(new java.awt.Dimension(120, 40));
                setLocation(new java.awt.Point(0, 0));
                setLayout(null);

                add(lblIput);
                add(InputTxt);
                add(cmdsign);
                add(Rtxt);
                add(Cmdverify);
                add(cmdhash);
                add(textField2);
                add(textField1);
                add(textField3);
                add(lbhash);
                add(lbS);
                add(lby);
                add(label2);
                add(lbverify);
                add(cmdReset);

                setSize(new java.awt.Dimension(650, 1320));

                // event handling
                cmdsign.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                                cmdsignActionPerformed(e);
                        }
                });
                Cmdverify.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                                CmdverifyActionPerformed(e);
                        }
                });
                cmdhash.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                                button3ActionPerformed(e);
                        }
                });
               
                cmdReset.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                                cmdResetActionPerformed(e);
                        }
                });
               

// END GENERATED CODE
        }


回复

使用道具 举报

203

主题

0

好友

2800

积分

认证卖家

Rank: 50Rank: 50Rank: 50Rank: 50Rank: 50

3#
发表于 2009-6-26 02:36 AM |只看该作者
/**************************************************************************************************

        public BigInteger generate_rand() {
                byte[] bval = new byte[20];
                SecureRandom rnd = new SecureRandom();
                rnd.nextBytes(bval);

                BigInteger rnd_seed = new BigInteger(bval);
                return rnd_seed;
        } // generate_rand()


        public BigInteger hshcall(String M){
                byte[] toMessageDigest = M.getBytes();
                byte[] hash_message = new byte[20];
                BigInteger h;
               
                try{
                        MessageDigest md4 = MessageDigest.getInstance("SHA-1");
                            md4.update(toMessageDigest);
                        hash_message = md4.digest();
                }
                catch (NoSuchAlgorithmException nsae) {
                        System.err.println("Caught NSAException: " + nsae.getMessage());
                }
               
                h = new BigInteger(hash_message);
                return h.abs();
        } // hshcall()   



//***********************************************************************************************

public void signMethod()
        {

                try {

                        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN");
                        SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
                        keyGen.initialize(1024, random);
                        KeyPair pair = keyGen.generateKeyPair();
                        PrivateKey priv = pair.getPrivate();
                        PublicKey pub = pair.getPublic();

//Generating P , Q and G
       
                        P = new BigInteger(p1,16);
                        Q = new BigInteger(q1,16);
                        G = new BigInteger(g1,16);

// Generating x , y and K
       
       
                do {

                        x = generate_rand();               
                        X = x.abs();

                        k = generate_rand();
                        K = k.abs();
       
                        xcmp = X.compareTo(Q);
                        kcmp = K.compareTo(Q);
       
                } while (xcmp != -1 && kcmp != -1);

                Y = G.modPow(X,P);
       
// Signing the message m


                R = (G.modPow(K,P)).mod(Q);
                Rtxt.setText(R.toString());

                BigInteger Kinv = K.modInverse(Q);        
       
                BigInteger Sint1 = X.multiply(R);
                BigInteger Sint2 = hshm.add(Sint1);
                BigInteger Sint3 = Kinv.multiply(Sint2);
                S = Sint3.mod(Q);
                textField2.setText(S.toString());
       
                textField1.setText(Y.toString());
        } catch (Exception e) {
            System.err.println("Caught exception " + e.toString());
        }


        } // signMethod()


//******************************************* action performed*************************

        public void cmdsignActionPerformed(java.awt.event.ActionEvent e) {
             signMethod();

        }
       
        public void button3ActionPerformed(java.awt.event.ActionEvent e) {
            m = InputTxt.getText();
                        hshm = hshcall(m);
                        textField3.setText(hshm.toString());

        }
       
        public void CmdverifyActionPerformed(java.awt.event.ActionEvent e) {
        
                try {
       
                                BigInteger Sinp,hshminp,Rinp,Yinp;
       
                                Sinp = new BigInteger(textField2.getText());
                                hshminp = new BigInteger(textField3.getText());
                                Rinp = new BigInteger(Rtxt.getText());
                                Yinp = new BigInteger(textField1.getText());
                                int Sinpcmp = Sinp.compareTo(Q);
                                int Rinpcmp = Rinp.compareTo(Q);
       
                                if (Sinpcmp == -1 && Rinpcmp == -1) {
       
                               
                                        BigInteger W,U1,U2,Vint1,Vint2,Vint3,Vint4,V;

                                        W = Sinp.modInverse(Q);
                                        U1 = (hshminp.multiply(W)).mod(Q);
                                        U2 = (Rinp.multiply(W)).mod(Q);
                                        Vint1 = (G.modPow(U1,P));
                                        Vint2 = Yinp.modPow(U2,P);
                                        Vint3 = Vint1.multiply(Vint2);
                                        Vint4 = Vint3.mod(P);
                                        V = Vint4.mod(Q);
               
                                        int Vcmp = V.compareTo(Rinp);
       
                                        if (Vcmp == 0)lbverify.setText("The signature is verified.");
                                        else lbverify.setText("The signature has failed to verify.");
       

                                }else lbverify.setText("The signature has failed to verify");
                        }catch (Exception e1) {
                                System.err.println("Caught exception " + e1.toString());
                        }

                                       
        }
       
        public void cmdResetActionPerformed(java.awt.event.ActionEvent e) {
       
                InputTxt.setText("");       
                        textField3.setText("");
                        Rtxt.setText("");               
                        textField2.setText("");               
                        textField1.setText("");               
                        lbverify.setText("To Be Verified");               

       
       
        }
       
       
}


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

4#
发表于 2009-6-26 02:37 AM |只看该作者
原帖由 理想の情人 于 2009-6-26 02:17 AM 发表
--------------------Configuration: --------------------
java.lang.NoSuchMethodError: main
Exception in thread "main"
Process completed.

请问为什么会这样呢?
build file是没有问题
但是 run  ...


請問你的入口函數 Public static void main 到哪去了?

[ 本帖最后由 Super-Tomato 于 2009-6-26 02:39 AM 编辑 ]


回复

使用道具 举报

203

主题

0

好友

2800

积分

认证卖家

Rank: 50Rank: 50Rank: 50Rank: 50Rank: 50

5#
发表于 2009-6-26 09:40 AM |只看该作者
那我现在应该怎么做呢.....


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

6#
发表于 2009-6-26 09:48 AM |只看该作者
原帖由 理想の情人 于 2009-6-26 09:40 AM 发表
那我现在应该怎么做呢.....



程式是你的, 當然該問你怎麼寫個入口函數 main 去執行才對


回复

使用道具 举报

203

主题

0

好友

2800

积分

认证卖家

Rank: 50Rank: 50Rank: 50Rank: 50Rank: 50

7#
发表于 2009-6-26 09:57 AM |只看该作者
这是上网找到的, 我只是想看看结果罢了.... 那没关系.. 谢谢哦


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-28 03:33 PM , Processed in 0.114675 second(s), 27 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部