Could not find or load main Class on JAR executing

后端 未结 2 1069
长情又很酷
长情又很酷 2020-12-10 20:15

I finished my project (in NetBeans) and i export Jar file (i set my main class in project properties correctly before exporting Jar):<

相关标签:
2条回答
  • 2020-12-10 20:24

    So,here comes an error to the problem---why have you mentioned con = DriverManager.getConnection(...); in your code?

    And hence your code is catching SQL Exception!!! This is the source of error :-

    public boolean userEnterCondition(char[] pass) {
    Connection con;
    PreparedStatement preparedStatement;
    ResultSet resultSet;
    String query = "Select * from users";
    String password = null;
    try {
        Class.forName("com.mysql.jdbc.Driver");
        con = DriverManager.getConnection(...);     //error in this line
    
    ................. and so on.
    

    Replace it with

    con =DriverManager.getConnection("jdbc:mysql://localhost/Library?" +
                                   "user=yourusername&password=yourpassword");
    

    I hope this helps.If still getting error,please comment below!

    0 讨论(0)
  • 2020-12-10 20:25

    Open your jar file with WinRAR or a similar program. Then go to the META-INF folder and open the MANIFEST.MF. Make sure the property "Main-Class: your.class.path" is correct.

    0 讨论(0)
提交回复
热议问题