Hallo,
cih habe folgenden Code:
Wenn ich ein JAR erstelle und die Zeilen 232 + 233 auskommentiere funktioniert alles super, mit den Zeilen bekomme ich folgende Fehlermeldung, wenn ich das JAR ausführe: "Could not find the main class. Program will exit."
Was ist denn an diesen Zeilen falsch??? Wenn ich meinen Code in der Programmierumgebung starte funktioniert alles ohne Fehler.
Danke
cih habe folgenden Code:
Code:
package main;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class MainFrame extends JFrame
{
public Vector selProd = new Vector();
private JDesktopPane desktop = new JDesktopPane();
private InputFrame input;
private OutputFrame output1;
private OutputFrame output2;
private BorderLayout borderLayout1 = new BorderLayout();
private boolean showOutput = false;
private JRadioButtonMenuItem mnuAll = new JRadioButtonMenuItem();
private JRadioButtonMenuItem mnuSingle = new JRadioButtonMenuItem();
private Calculation calcNew;
public static void main(String[] args)
{
new MainFrame();
}
public MainFrame()
{
try
{
jbInit();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
createDesktop();
createInput();
}
private void createDesktop()
{
// Haupteinstellungen
this.getContentPane().setLayout(borderLayout1);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(new Dimension(800,600));
this.setTitle("GGB Selection Guide");
// Menuleiste
JMenuBar menu = new JMenuBar();
JMenu mnuFile = new JMenu();
JMenuItem mnuExit = new JMenuItem();
JMenu mnuHelp = new JMenu();
JMenuItem mnuInfo = new JMenuItem();
JMenu mnuProd = new JMenu();
mnuFile.setText("File");
mnuExit.setText("Exit");
mnuExit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
System.exit(0);
}
});
mnuFile.add(mnuExit);
menu.add(mnuFile);
ButtonGroup groupProduct = new ButtonGroup();
mnuAll.setText("Select All");
mnuAll.setSelected(true);
groupProduct.add(mnuAll);
mnuAll.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
setSelectedProduct(true);
}
});
mnuSingle.setText("Select Products");
groupProduct.add(mnuSingle);
mnuSingle.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
setSelectedProduct(false);
}
});
mnuProd.setText("Product");
mnuProd.add(mnuAll);
mnuProd.add(mnuSingle);
menu.add(mnuProd);
setSelectedProduct(true); //alle Produkte in selProd übernehmen
mnuHelp.setText("?");
mnuInfo.setText("Info");
mnuInfo.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(desktop,
"this", "Info",
JOptionPane.INFORMATION_MESSAGE);
}
});
mnuHelp.add(mnuInfo);
menu.add(mnuHelp);
this.setJMenuBar(menu);
// Desktop
this.getContentPane().add(desktop, BorderLayout.CENTER);
this.setVisible(true);
}
private void setSelectedProduct(boolean all)
{
if (all)
{
SelectProduct selectProduct = new SelectProduct(this, "Select Product", true, true);
selProd.clear();
for (int i = 0; i < selectProduct.prodSelected.size(); i++)
{
selProd.addElement(selectProduct.prodSelected.elementAt(i));
//System.out.println(selProd.lastElement().toString());
}
}
else
{
SelectProduct selectProduct = new SelectProduct(this, "Select Product", true, false);
selectProduct.getProduct(selProd);
selectProduct.setVisible(true);
if (selectProduct.prodSelected.size() == selectProduct.chkProduct.length)
{
mnuAll.setSelected(true);
mnuSingle.setSelected(false);
}
selProd.clear();
for (int i = 0; i < selectProduct.prodSelected.size(); i++)
{
selProd.addElement(selectProduct.prodSelected.elementAt(i));
//System.out.println(selProd.lastElement().toString());
}
}
}
private void createInput()
{
input = new InputFrame("Values for Calculation", false, false, false, true);
input.setBounds(5,5,780,290);
input.setMinimumSize(new Dimension(760,290));
input.btnCalculate.setText("Calculate");
input.btnCalculate.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
calcProduct();
}
});
desktop.add(input);
input.setVisible(true);
desktop.revalidate();
}
private void calcProduct()
{
Vector Input = new Vector();
for (int i = 0; i < 5; i++)
{
Input.insertElementAt(Double.parseDouble(input.txtInput[i].getText().replace(',', '.')), i);
}
if (input.iStep1 == 0)
{ Input.insertElementAt(Double.parseDouble(input.txtInput[5].getText().replace(',', '.')),5);
Input.insertElementAt(Double.parseDouble("0"),6); }
else
{ Input.insertElementAt(Double.parseDouble("0"),5);
Input.insertElementAt(Double.parseDouble(input.txtInput[5].getText().replace(',', '.')),6); }
if ((input.iStep2 == 0) || (input.iStep2 == 4))
{
Input.insertElementAt(Double.parseDouble(input.txtInput[6].getText().replace(',', '.')), 7);
Input.insertElementAt(Double.parseDouble("0"), 8);
Input.insertElementAt(Double.parseDouble("0"), 9);
Input.insertElementAt(Double.parseDouble("0"), 10);
Input.insertElementAt(Double.parseDouble("0"), 11);
Input.insertElementAt(Double.parseDouble("0"), 12);
}
else if ((input.iStep2 == 1) || (input.iStep2 == 3))
{
Input.insertElementAt(Double.parseDouble("0"), 7);
Input.insertElementAt(Double.parseDouble(input.txtInput[6].getText().replace(',', '.')), 8);
Input.insertElementAt(Double.parseDouble(input.txtInput[7].getText().replace(',', '.')), 9);
Input.insertElementAt(Double.parseDouble(input.txtInput[8].getText().replace(',', '.')), 10);
Input.insertElementAt(Double.parseDouble("0"), 11);
Input.insertElementAt(Double.parseDouble("0"), 12);
}
else if (input.iStep2 == 2)
{
Input.insertElementAt(Double.parseDouble("0"), 7);
Input.insertElementAt(Double.parseDouble(input.txtInput[6].getText().replace(',', '.')), 8);
Input.insertElementAt(Double.parseDouble(input.txtInput[7].getText().replace(',', '.')), 9);
Input.insertElementAt(Double.parseDouble("0"), 10);
Input.insertElementAt(Double.parseDouble(input.txtInput[8].getText().replace(',', '.')), 11);
Input.insertElementAt(Double.parseDouble(input.txtInput[9].getText().replace(',', '.')), 12);
}
calcNew = new Calculation(Input, selProd, input.iStep2, input.iStep1);
createOutput();
}
private void createOutput()
{
if (output1 != null) output1.dispose();
String[] header1 = { "bla", "bla1", "bla2", ...};
String[] colToolTip1 = { "bla", "bla1", "bla2", ...};
output1 = new OutputFrame("Dimensions", true, true, true, true,
calcNew.tableData1, selProd, header1, false, colToolTip1);
output1.setBounds(80,80,700,300);
if (output2 != null) output2.dispose();
String[] header2 = { "bla", "bla1", "bla2", ...};
String[] colToolTip2 = { "bla", "bla1", "bla2", ...};
output2 = new OutputFrame("Dimensionless Numbers", true, true, true, true,
calcNew.tableData2, selProd, header2, true, colToolTip2);
output2.setBounds(40,40,700,300);
desktop.add(output2);
desktop.add(output1);
output2.setVisible(true);
output1.setVisible(true);
}
}
Wenn ich ein JAR erstelle und die Zeilen 232 + 233 auskommentiere funktioniert alles super, mit den Zeilen bekomme ich folgende Fehlermeldung, wenn ich das JAR ausführe: "Could not find the main class. Program will exit."
Was ist denn an diesen Zeilen falsch??? Wenn ich meinen Code in der Programmierumgebung starte funktioniert alles ohne Fehler.
Danke