简体   繁体   中英

Illegal start of expression error in java swing auto-generated code

I am using Java Swing to create a GUI.

import javax.swing.*;
import javax.swing.filechooser.*;
import javax.swing.InputVerifier;
import java.lang.Process;
import java.lang.ProcessBuilder;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

It is telling me that the line " private void outputDirActionPerformed..." has an illegal start of expression, however that line of code is autogenerated by NetBeans. commandPLINK is an array of parameters, and is behaving correctly.

    ProcessBuilder pb = new ProcessBuilder(commandPLINK);

    try {
        pb.inheritIO();
        Process p = pb.start();
    } catch (IOException ex) {
        Logger.getLogger(rtPCRGui.class.getName()).log(Level.SEVERE, null, ex);
    }
}   //convertButtonActionPerformed                                          

private void outputDirActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
} 

Any idea what might be happening that's causing the autogenerated code to throw this error?

This error happens when you are missing a } somewhere before the line that triggers the error. You should look at the preceding method and see if every { is matched with a corresponding } .

Also, you may look if there is an extra } after the generated method.

To be more clear, this error means that the compiler did not expect to have a function definition starting there, because it is believing that you are still in a method block, and a method can not be inside another method.

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