简体   繁体   中英

Exception thrown when compiling on Emacs but not on Netbeans IDE

I'm new to java and have developed a simple calculator using Swing and pushed it to github. ( https://github.com/christopherkade/SwingCalculator )

I coded it on Netbeans IDE and downloaded my .zip from github to try it out through emacs.

Note that the IDE does not throw any exceptions when doing the same actions.

I compile as follows:

javac calc/CalculatorGUI.java

java calc.CalculatorGUI

The calculator launches without a problem, but after the second click it throws me the following:

Exception in thread "AWT-EventQueue-0" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: java/lang/invoke/StringConcatFactory
at calc.CalculatorGUI.operatorButtonActionPerformed(CalculatorGUI.java:323)

Where the line concerned is in:

private void operatorButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
   if (op == ' ') {
        op = evt.getActionCommand().charAt(0);
        String str = resultLabel.getText();
        str += " " + evt.getActionCommand() + " ";
        resultLabel.setText(str);
    }
}                                              

Does my problem come from the way I compile it or my code?

Thank you

On the console type:

java -version

and check if NetBeans uses the same JDK as you use when compiling/running from the command line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM