Hi, after adding the declarations (quick and dirty)
public JTextField tfISfile; public JTextField tfIfile; public JTextField tfIPfile; public JTextArea tbISfileinfo; public JTextField tfRuns; It runs ok for me. Manifest is ok, can be run by double-click on the .jar NB 21, Windows 11 regards Am 15.04.2024 um 02:49 schrieb Brian Allison (ISSRS):
I can build and run my jFrame project in Netbeans IDE 21. If I go to the folder where my .jar file is and double click on it, nothing happens. If I go to a console and run it with the command java -jar BFC.jar I get an error no main manifest attribute, in BFC.jar If I use the command java xf BFG.jar and look at the MANIFEST file, there is no Main-Class line. After I add the line with the main class, I get this error. Error: Could not find or load main class iss.batchfilegenerator.BFG Caused by: java.lang.ClassNotFoundException: iss.batchfilegenerator.BFG In net beans I have iss.batchfilegenerator.BFG. specified as the main class under project|properties |Run. Here is the code package iss.batchfilegenerator; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; import java.io.File; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import javax.swing.JOptionPane; /** * * @author brianallison */ public class BFG extends javax.swing.JFrame { public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(BFG.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(() -> { new BFG().setVisible(true); }); } /** * Creates new form BFG */ public BFG() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); tfISfile = new javax.swing.JTextField(); tfIfile = new javax.swing.JTextField(); tfIPfile = new javax.swing.JTextField(); btnISfile = new javax.swing.JButton(); btnIfile = new javax.swing.JButton(); btnIPfile = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); tbISfileinfo = new javax.swing.JTextArea(); btnBatchfile = new javax.swing.JButton(); btnSavedata = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); tfRuns = new javax.swing.JTextField(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setName("fBFG"); // NOI18N jLabel1.setFont(new java.awt.Font("Helvetica Neue", 1, 24)); // NOI18N jLabel1.setText("Integrated Uncertainty Analysis"); jLabel2.setFont(new java.awt.Font("Helvetica Neue", 1, 24)); // NOI18N jLabel2.setText("Batch File Creator"); jLabel3.setText("Choose .IS File"); jLabel3.setToolTipText(""); jLabel4.setText("Choose .i FIle"); jLabel5.setText("Choose .ip File"); btnISfile.setText("Choose File"); btnISfile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnISfileActionPerformed(evt); } }); btnIfile.setText("Choose File"); btnIfile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnIfileActionPerformed(evt); } }); btnIPfile.setText("Choose File"); btnIPfile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnIPfileActionPerformed(evt); } }); tbISfileinfo.setColumns(20); tbISfileinfo.setRows(5); jScrollPane1.setViewportView(tbISfileinfo); btnBatchfile.setText("Create Batch data"); btnBatchfile.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBatchfileActionPerformed(evt); } }); btnSavedata.setFont(new java.awt.Font("Helvetica Neue", 1, 14)); // NOI18N btnSavedata.setText("Save Batch Data"); btnSavedata.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSavedataActionPerformed(evt); } }); jLabel6.setText("Number of Runs Needed (Default is 59)"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(btnSavedata, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1)) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(27, 27, 27) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addComponent(jLabel5) .addGap(18, 18, 18) .addComponent(tfIPfile)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel4) .addGap(26, 26, 26) .addComponent(tfIfile)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(jLabel3) .addGap(18, 18, 18) .addComponent(tfISfile, javax.swing.GroupLayout.PREFERRED_SIZE, 355, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel6) .addGap(18, 18, 18) .addComponent(tfRuns))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btnISfile) .addComponent(btnIfile) .addComponent(btnIPfile) .addComponent(btnBatchfile))) .addGroup(layout.createSequentialGroup() .addGap(232, 232, 232) .addComponent(jLabel2)) .addGroup(layout.createSequentialGroup() .addGap(162, 162, 162) .addComponent(jLabel1))) .addGap(0, 62, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(19, 19, 19) .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel2) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(tfISfile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnISfile)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(tfIfile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnIfile)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(tfIPfile, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnIPfile)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(tfRuns, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnBatchfile)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnSavedata, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); pack(); }// </editor-fold> private void btnISfileActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new FileNameExtensionFilter("IS Files", "is")); int result = chooser.showOpenDialog(this); if (result == JFileChooser.APPROVE_OPTION) { String selectedFile = chooser.getSelectedFile().getAbsolutePath(); tfISfile.setText(selectedFile); } } private void btnIfileActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new FileNameExtensionFilter("I Files", "i")); int result = chooser.showOpenDialog(this); if (result == JFileChooser.APPROVE_OPTION) { String selectedFile = chooser.getSelectedFile().getAbsolutePath(); tfIfile.setText(selectedFile); } } private void btnIPfileActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new FileNameExtensionFilter("IP Files", "ip")); int result = chooser.showOpenDialog(this); if (result == JFileChooser.APPROVE_OPTION) { String selectedFile = chooser.getSelectedFile().getAbsolutePath(); tfIPfile.setText(selectedFile); } } private void btnBatchfileActionPerformed(java.awt.event.ActionEvent evt) { // Check if all text fields are filled if (!tfISfile.getText().isEmpty() && !tfIfile.getText().isEmpty() && !tfIPfile.getText().isEmpty()) { // Generate batch file content String batchFileContent = generateBatchFileContent(); // Display batch file content in text area tbISfileinfo.setText(batchFileContent); } else { JOptionPane.showMessageDialog(this, "Please fill in all three text fields."); } } private void btnSavedataActionPerformed(java.awt.event.ActionEvent evt) { // Check if there is content in the text area if (!tbISfileinfo.getText().isEmpty()) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("Save Batch File"); int result = chooser.showSaveDialog(this); if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = chooser.getSelectedFile(); String fileName = selectedFile.getAbsolutePath(); if (!fileName.endsWith(".bat")) { fileName += ".bat"; } try { BufferedWriter writer = new BufferedWriter(new FileWriter(fileName)); writer.write(tbISfileinfo.getText()); writer.close(); JOptionPane.showMessageDialog(this, "Batch file saved successfully."); } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error saving batch file: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(this, "No batch file content to save.", "Warning", JOptionPane.WARNING_MESSAGE); } } private String generateBatchFileContent() { String isFileName = tfISfile.getText().trim(); String iFileName = tfIfile.getText().trim(); String ipFileName = tfIPfile.getText().trim(); int numberOfRuns; // Check if the runs text field is empty or not if (!tfRuns.getText().isEmpty()) { numberOfRuns = Integer.parseInt(tfRuns.getText()); } else { // Default to 59 runs if the text field is empty numberOfRuns = 59; } StringBuilder content = new StringBuilder(); // Generate batch file content based on the file names and number of runs content.append("aecho on\n"); content.append("del outdta\n"); content.append("del *.w\n"); content.append("del *.o\n"); content.append("del *.r\n"); content.append("del *.m\n"); content.append("del *.os\n"); content.append("del *.rs\n"); content.append("del *.op\n"); content.append("del *.mruns\n"); content.append("relap5.exe -i \"").append(isFileName).append("\" -U setup -Q\n"); content.append("pause\n"); content.append("relap5.exe -i \"").append(iFileName).append("\" -U 0 -Q\n"); // Generate commands for additional runs for (int i = 1; i <= numberOfRuns; i++) { content.append("relap5.exe -i \"").append(iFileName).append("\" -U ").append(i).append(" -Q\n"); } content.append("relap5.exe -i \"").append(ipFileName).append("\" -U postpr\n"); return content.toString(); }
-- Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft. www.avast.com
BEGIN:VCARD FN:Helmut Leininger N:Leininger;Helmut;;; EMAIL:h.leinin...@gmx.at X-MOZILLA-HTML:TRUE END:VCARD
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org For additional commands, e-mail: users-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists