You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by "Brian Allison (ISSRS)" <is...@gmail.com> on 2024/04/15 00:49:50 UTC
Main class problem with Netbeans IDE 21
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 <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();
}
Re: Main class problem with Netbeans IDE 21
Posted by Helmut Leininger <h....@gmx.at.INVALID>.
Replaced my insertions by youroriginal. Still runs ok.
Am 15.04.2024 um 18:22 schrieb Helmut Leininger:
>
> Sorry, but this was not in your mail. So I had to declare some
> variables (some of them could be local).
>
> Regards
>
> Am 15.04.2024 um 17:37 schrieb Brian Allison (ISSRS):
>>
>>
>>> On Apr 15, 2024, at 9:36 AM, Brian Allison (ISSRS)
>>> <is...@gmail.com> wrote:
>>>
>>>
>>>
>>>> On Apr 15, 2024, at 5:16 AM, Helmut Leininger
>>>> <h....@gmx.at.INVALID> wrote:
>>>>
>>>> public JTextField tfISfile;
>>>> public JTextField tfIfile;
>>>> public JTextField tfIPfile;
>>>> public JTextArea tbISfileinfo;
>>>> public JTextField tfRuns;
>>>
>>> This is already declared at the bottom of my code.
>>>
>>> // Variables declaration - do not modify
>>> private javax.swing.JButton btnBatchfile;
>>> private javax.swing.JButton btnIPfile;
>>> private javax.swing.JButton btnISFC;
>>> private javax.swing.JButton btnISfile;
>>> private javax.swing.JButton btnIfile;
>>> private javax.swing.JButton btnSavedata;
>>> private javax.swing.JLabel jLabel1;
>>> private javax.swing.JLabel jLabel2;
>>> private javax.swing.JLabel jLabel3;
>>> private javax.swing.JLabel jLabel4;
>>> private javax.swing.JLabel jLabel5;
>>> private javax.swing.JLabel jLabel6;
>>> private javax.swing.JScrollPane jScrollPane1;
>>> private javax.swing.JTextArea tbISfileinfo;
>>> private javax.swing.JTextField tfIPfile;
>>> private javax.swing.JTextField tfISfile;
>>> private javax.swing.JTextField tfIfile;
>>> private javax.swing.JTextField tfRuns;
>>> // End of variables declaration
>>>
>>>
>>> Brian
>>>
>>
>>> On Apr 15, 2024, at 5:16 AM, Helmut Leininger
>>> <h....@gmx.at.INVALID> wrote:
>>>
>>> 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();
>>>> }
>>>
>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
>>> Virenfrei.www.avast.com
>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
>>>
>>>
>>> <x-msg://3/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>> <h_leininger.vcf>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
>>> <ma...@netbeans.apache.org>
>>> For additional commands, e-mail: users-help@netbeans.apache.org
>>> <ma...@netbeans.apache.org>
>>>
>>> For further information about the NetBeans mailing lists, visit:
>>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail:users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
--
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com
Re: Main class problem with Netbeans IDE 21
Posted by Helmut Leininger <h....@gmx.at.INVALID>.
Sorry, but this was not in your mail. So I had to declare some variables
(some of them could be local).
Regards
Am 15.04.2024 um 17:37 schrieb Brian Allison (ISSRS):
>
>
>> On Apr 15, 2024, at 9:36 AM, Brian Allison (ISSRS)
>> <is...@gmail.com> wrote:
>>
>>
>>
>>> On Apr 15, 2024, at 5:16 AM, Helmut Leininger
>>> <h....@gmx.at.INVALID> wrote:
>>>
>>> public JTextField tfISfile;
>>> public JTextField tfIfile;
>>> public JTextField tfIPfile;
>>> public JTextArea tbISfileinfo;
>>> public JTextField tfRuns;
>>
>> This is already declared at the bottom of my code.
>>
>> // Variables declaration - do not modify
>> private javax.swing.JButton btnBatchfile;
>> private javax.swing.JButton btnIPfile;
>> private javax.swing.JButton btnISFC;
>> private javax.swing.JButton btnISfile;
>> private javax.swing.JButton btnIfile;
>> private javax.swing.JButton btnSavedata;
>> private javax.swing.JLabel jLabel1;
>> private javax.swing.JLabel jLabel2;
>> private javax.swing.JLabel jLabel3;
>> private javax.swing.JLabel jLabel4;
>> private javax.swing.JLabel jLabel5;
>> private javax.swing.JLabel jLabel6;
>> private javax.swing.JScrollPane jScrollPane1;
>> private javax.swing.JTextArea tbISfileinfo;
>> private javax.swing.JTextField tfIPfile;
>> private javax.swing.JTextField tfISfile;
>> private javax.swing.JTextField tfIfile;
>> private javax.swing.JTextField tfRuns;
>> // End of variables declaration
>>
>>
>> Brian
>>
>
>> On Apr 15, 2024, at 5:16 AM, Helmut Leininger
>> <h....@gmx.at.INVALID> wrote:
>>
>> 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();
>>> }
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
>> Virenfrei.www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
>>
>>
>> <x-msg://3/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>> <h_leininger.vcf>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
>> <ma...@netbeans.apache.org>
>> For additional commands, e-mail: users-help@netbeans.apache.org
>> <ma...@netbeans.apache.org>
>>
>> For further information about the NetBeans mailing lists, visit:
>> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
>
--
Diese E-Mail wurde von Avast-Antivirussoftware auf Viren geprüft.
www.avast.com
Re: Main class problem with Netbeans IDE 21
Posted by "Brian Allison (ISSRS)" <is...@gmail.com>.
> On Apr 15, 2024, at 9:36 AM, Brian Allison (ISSRS) <is...@gmail.com> wrote:
>
>
>
>> On Apr 15, 2024, at 5:16 AM, Helmut Leininger <h.leininger@gmx.at.INVALID <ma...@gmx.at.INVALID>> wrote:
>>
>> public JTextField tfISfile;
>> public JTextField tfIfile;
>> public JTextField tfIPfile;
>> public JTextArea tbISfileinfo;
>> public JTextField tfRuns;
>
> This is already declared at the bottom of my code.
>
> // Variables declaration - do not modify
> private javax.swing.JButton btnBatchfile;
> private javax.swing.JButton btnIPfile;
> private javax.swing.JButton btnISFC;
> private javax.swing.JButton btnISfile;
> private javax.swing.JButton btnIfile;
> private javax.swing.JButton btnSavedata;
> private javax.swing.JLabel jLabel1;
> private javax.swing.JLabel jLabel2;
> private javax.swing.JLabel jLabel3;
> private javax.swing.JLabel jLabel4;
> private javax.swing.JLabel jLabel5;
> private javax.swing.JLabel jLabel6;
> private javax.swing.JScrollPane jScrollPane1;
> private javax.swing.JTextArea tbISfileinfo;
> private javax.swing.JTextField tfIPfile;
> private javax.swing.JTextField tfISfile;
> private javax.swing.JTextField tfIfile;
> private javax.swing.JTextField tfRuns;
> // End of variables declaration
>
>
> Brian
>
> On Apr 15, 2024, at 5:16 AM, Helmut Leininger <h....@gmx.at.INVALID> wrote:
>
> 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 <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();
>> }
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Virenfrei.www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> <x-msg://3/#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2><h_leininger.vcf>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
> For additional commands, e-mail: users-help@netbeans.apache.org
>
> For further information about the NetBeans mailing lists, visit:
> https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: Main class problem with Netbeans IDE 21
Posted by Helmut Leininger <h....@gmx.at.INVALID>.
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