Reputation: 25
I use parse4j to let user sign up an account and sign in so User can view Their score online the problem is I cannot run my app and It says a lot of error
I import the parse4j-1.0.jar file to my eclipse project and I write as the instruction
This is my code
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();
}
}
and the errors are
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
I don't understand why this happen
Any help is appreciated, let me know if you need any additional information!
Thank you
UPDATE
I've import parse4j-1.0.jar and json-20150729.jar and the error has changed to
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
Upvotes: 2
Views: 185
Reputation: 159754
parse4j
has a JSON dependency whose jar file needs to be on the classpath when running the application. If youre using Maven you can simply use the dependency
<dependency>
<groupId>com.github.thiagolocatelli</groupId>
<artifactId>parse4j</artifactId>
<version>1.0</version>
</dependency>
Upvotes: 1
Reputation: 2277
From Documentation
NoClassDefFoundError is thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.
Upvotes: 0