我使用parse4j允许用户注册帐户并登录,以便用户可以在线查看其分数。问题是我无法运行我的应用程序,并且提示很多错误

我将parse4j-1.0.jar文件导入到我的eclipse项目中,并按照指令编写

这是我的代码

    package com.card.lab;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import org.parse4j.ParseException;
import org.parse4j.ParseUser;
import org.parse4j.callback.LoginCallback;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.parse4j.callback.*;
import org.parse4j.*;

public class SignIN extends JFrame{
    JTextField user = new JTextField();
    JTextField pass = new JTextField();
    JButton signIn = new JButton();
    JButton signUp = new JButton();
      ParseUser userr = new ParseUser();
      ParseUser sign = new ParseUser();

      LoginCallback back;
    SignIN(){
        Parse.initialize("jNKMBNdtX5Vq9tS6jVsNLEO89fvZQ1el2D3xnTeP","ZnhzdUVXXaiDGQRfn1lOXifclxSFQDW18Y7gbQBb");
        this.setLayout(new GridLayout(4,1));
        this.setBackground(new Color(222,252,226));
      this.setSize(400,400);
      signIn.setText("SIGN IN");
      signUp.setText("SIGN UP");
      this.add(user);
      this.add(pass);
      this.add(signIn);
      this.add(signUp);
      this.setVisible(true);
      signUp.addActionListener(new ActionListener(){

        @Override
        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub

            userr.setUsername(user.getText());
            userr.setPassword(pass.getText());
            try {
                userr.signUp();
                userr.loginInBackground(user.getText(), pass.getText(),back);
                if(sign!=null){
                    System.out.println("LOG IN");
                }
                else{
                    System.out.println("ERROR SIGN IN");
                }
                dispatch();
            } catch (ParseException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }

      });
      signIn.addActionListener(new ActionListener(){

        @Override
        public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            sign.loginInBackground(user.getText(), pass.getText(),back);
            if(sign!=null){
                System.out.println("LOG IN");
            }
            else{
                System.out.println("ERROR SIGN IN");
            }
        }

      });
    }
    public void dispatch(){
        this.setVisible(false);
        this.dispose();
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
          new SignIN();
    }

}


错误是

    Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
    at com.card.lab.SignIN.<init>(SignIN.java:24)
    at com.card.lab.SignIN.main(SignIN.java:87)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more


我不明白为什么会这样

感谢您的帮助,如果您需要其他任何信息,请告诉我!

谢谢

更新

我已经导入parse4j-1.0.jar和json-20150729.jar,错误已更改为

 Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at org.parse4j.ParseObject.<clinit>(ParseObject.java:42)
    at com.card.lab.SignIN.<init>(SignIN.java:25)
    at com.card.lab.SignIN.main(SignIN.java:88)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 3 more

最佳答案

parse4j具有JSON依赖性,运行应用程序时其jar file必须位于类路径中。如果您使用Maven,则只需使用依赖项

<dependency>
    <groupId>com.github.thiagolocatelli</groupId>
    <artifactId>parse4j</artifactId>
    <version>1.0</version>
</dependency>

关于java - Parse4j错误JAVA Eclipse,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33481687/

10-08 23:25