so :
meine Freunde der Sonne ich hab folgendes Problem,wenn ich diese Quelltext als Anwendung haben möchte, ´kommt folgender Fehler :
Exception in thread "main"java.lang.NoClassDefFoundError: BDEPortal/Java
so darauf hin hab ich die Main rein gebastelt nun weis ich allerdings nich warum das Fenster nich auf geht. Wenn ich es unter Eclipse als Bean durch jage Funktioniert es ja.Allerdings weis ich nich wie ich in der Eingabeaufforderung aufferufen kann ich hab da viel arbeit rein gesteck das jetzt der 3 Tag an dem ich mich mit Java beschäftige eigentlich will ich nur wissen,was in die Main rein muss damit der Frame aufgeht!!!!Eigentlich hab ich immer gedacht BDEPortal() also der Konstruktor erledigt das aber naja was muss ich also nun noch in die Main schreiben??
mfg da KOKser
Edit von L-ectron-X: Titel angepasst.
Code:
import javax.swing.JFrame;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.StringWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.Timer;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.lang.String;
import java.lang.reflect.Method;
/*
* Created on 06.06.2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author mk
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class BDEPortal extends JFrame {
private javax.swing.JPanel jContentPane = null;
private JButton jButton = null;
private JButton jButton1 = null;
private JButton jButton2 = null;
private JButton jButton3 = null;
private JLabel jLabel = null;
private JLabel initClock = null;
private JLabel muh = null;
char [] feld=new char [100];
private JLabel initClock() {
final DateFormat clockFormat = new SimpleDateFormat("HH:mm:ss");
final DateFormat stringFormat = new SimpleDateFormat("EEEE, d. MMMM yyyy");
final JLabel clock = new JLabel(clockFormat.format(new Date()));
clock.setToolTipText(stringFormat.format(new Date()));
clock.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 21));
clock.setPreferredSize(new java.awt.Dimension(400,150));
clock.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
clock.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
final Timer clockTimer = new Timer(100, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
synchronized(clock.getTreeLock()) {
clock.setText(clockFormat.format(new Date()));
clock.setToolTipText(stringFormat.format(new Date()));
}
}
});
clockTimer.start();
return clock;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() throws IOException{
if (jButton == null) {
jButton = new JButton();
jButton.setText("Personalzeit erfassen (Kommen/Gehen)");
jButton.setToolTipText("Personalzeit erfassen (Kommen/Gehen)");
jButton.setPreferredSize(new java.awt.Dimension(400,50));
jButton.setName("TEST 1");
jButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
FileReader Eingabestrom = null;
StringWriter text = new StringWriter();
String hallo;
final String Ausgabe;
boolean ende=false;
char[]Gesamt=new char[101];
final char[]Zeile1=new char[100];
int gelesen = 0;
int i=0,a=0;
int counter=0;
try {
Eingabestrom = new FileReader("C:\\init.txt");
} catch (FileNotFoundException e) {
System.out.println("init.txt Datei konnte nich gefunden werden");// TODO Auto-generated catch block
e.printStackTrace();
}
while(!ende)
{
gelesen = Eingabestrom.read();
if(gelesen == -1)ende=true;
else
text.write((char)gelesen);
hallo = text.toString();
Gesamt = hallo.toCharArray();
}
for(i=0;;i++)
{
if(Gesamt[i]=='\n'){while(a<100){Zeile1[a]=' ';a++;}break;}
if(counter==0){a++;Zeile1[a]=Gesamt[i];}
}
hallo=String.valueOf(Zeile1);
Ausgabe=hallo.trim();
System.out.println(Ausgabe);
jButton.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
try {
Runtime.getRuntime().exec(Ausgabe);
} catch (IOException e1) {
e1.printStackTrace();
e1.getMessage();
}
}
});
}
return jButton;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setText("Arbeitschein anstempeln/rückmelden");
jButton1.setToolTipText("Arbeitschein anstempeln/rückmelden");
jButton1.setPreferredSize(new java.awt.Dimension(400,50));
jButton1.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
FileReader Eingabestrom = null;
StringWriter text = new StringWriter();
String hallo;
final String Ausgabe2;
boolean ende=false;
char[]Gesamt=new char[101];
final char[]Zeile2=new char[100];
int gelesen = 0;
int i=0,a=0;
int counter=0;
try {
Eingabestrom = new FileReader("C:\\init.txt");
} catch (FileNotFoundException e) {
System.out.println("init.txt Datei konnte nich gefunden werden");// TODO Auto-generated catch block
e.printStackTrace();
}
while(!ende)
{
try {
gelesen = Eingabestrom.read();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(gelesen == -1)ende=true;
else
text.write((char)gelesen);
hallo = text.toString();
Gesamt = hallo.toCharArray();
}
i=0;
a=0;
counter=0;
for(;;i++)
{
if(counter==2){while(a<100){Zeile2[a]=' ';a++;}break;}
if(Gesamt[i]=='\n')counter++;
if(counter==1){a++;Zeile2[a]=Gesamt[i];}
}
hallo=String.valueOf(Zeile2);
Ausgabe2=hallo.trim();
System.out.println(Ausgabe2);
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
try {
Runtime.getRuntime().exec(Ausgabe2);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
e1.getMessage();
}
}
});
}
return jButton1;
}
/**
* This method initializes jButton2
*
* @return javax.swing.JButton
*/
private JButton getJButton2() {
if (jButton2 == null) {
jButton2 = new JButton();
jButton2.setText("Info");
jButton2.setToolTipText("Info");
jButton2.setPreferredSize(new java.awt.Dimension(400,50));
jButton2.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
FileReader Eingabestrom = null;
StringWriter text = new StringWriter();
String hallo;
final String Ausgabe3;
boolean ende=false;
char[]Gesamt=new char[101];
final char[]Zeile3=new char[100];
int gelesen = 0;
int i=0,a=0;
int counter=0;
try {
Eingabestrom = new FileReader("C:\\init.txt");
} catch (FileNotFoundException e) {
System.out.println("init.txt Datei konnte nich gefunden werden");// TODO Auto-generated catch block
e.printStackTrace();
}
while(!ende)
{
try {
gelesen = Eingabestrom.read();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(gelesen == -1)ende=true;
else
text.write((char)gelesen);
hallo = text.toString();
Gesamt = hallo.toCharArray();
}
i=0;
a=0;
counter=0;
for(;;i++)
{
if(counter==3){while(a<100){Zeile3[a]=' ';a++;}break;}
if(Gesamt[i]=='\n')counter++;
if(counter==2){a++;Zeile3[a]=Gesamt[i];}
}
hallo=String.valueOf(Zeile3);
Ausgabe3=hallo.trim();
System.out.println(Ausgabe3);
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
try {
Runtime.getRuntime().exec(Ausgabe3);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
e1.getMessage();
} // TODO Auto-generated Event stub mouseClicked()
}
});
}
return jButton2;
}
/**
* This method initializes jButton3
*
* @return javax.swing.JButton
*/
private JButton getJButton3() {
if (jButton3 == null) {
jButton3 = new JButton();
jButton3.setText("Start abas-ERP");
jButton3.setToolTipText("Startet abas-ERP");
jButton3.setPreferredSize(new java.awt.Dimension(400,50));
jButton3.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
FileReader Eingabestrom = null;
StringWriter text = new StringWriter();
String hallo;
final String Ausgabe4;
boolean ende=false;
char[]Gesamt=new char[101];
final char[]Zeile4=new char[100];
int gelesen = 0;
int i=0,a=0;
int counter=0;
try {
Eingabestrom = new FileReader("C:\\init.txt");
} catch (FileNotFoundException e) {
System.out.println("init.txt Datei konnte nich gefunden werden");// TODO Auto-generated catch block
e.printStackTrace();
}
while(!ende)
{
try {
gelesen = Eingabestrom.read();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(gelesen == -1)ende=true;
else
text.write((char)gelesen);
hallo = text.toString();
Gesamt = hallo.toCharArray();
}
for(;;i++)
{
if(counter==4){while(a<100){Zeile4[a]=' ';a++;}break;}
if(Gesamt[i]=='\n')counter++;
if(counter==3){a++;Zeile4[a]=Gesamt[i];}
}
hallo=String.valueOf(Zeile4);
Ausgabe4=hallo.trim();
System.out.println(Ausgabe4);
jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
try {
Runtime.getRuntime().exec(Ausgabe4);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
e1.getMessage();
}
}
});
}
return jButton3;
}
/**
* This is the default constructor
*/
private JLabel getjLabel()
{
if (jLabel == null) {
jLabel = new JLabel();
jLabel.setVisible(true);
jLabel.setToolTipText("Logo");
jLabel.setPreferredSize(new java.awt.Dimension(296,100));
jLabel.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
jLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
FileReader Eingabestrom = null;
StringWriter text = new StringWriter();
String hallo;
final String Ausgabe5;
boolean ende=false;
char[]Gesamt=new char[101];
final char[]Zeile5=new char[100];
int gelesen = 0;
int i=0,a=0;
int counter=0;
try {
Eingabestrom = new FileReader("C:\\init.txt");
} catch (FileNotFoundException e) {
System.out.println("init.txt Datei konnte nich gefunden werden");// TODO Auto-generated catch block
e.printStackTrace();
}
while(!ende)
{
try {
gelesen = Eingabestrom.read();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(gelesen == -1)ende=true;
else
text.write((char)gelesen);
hallo = text.toString();
Gesamt = hallo.toCharArray();
}
i=0;
a=0;
counter=0;
for(;;i++)
{
if(counter==5){while(a<100){Zeile5[a]=' ';a++;}break;}
if(Gesamt[i]=='\n')counter++;
if(counter==4){a++;Zeile5[a]=Gesamt[i];}
}
hallo=String.valueOf(Zeile5);
Ausgabe5=hallo.trim();
System.out.println(Ausgabe5);
jLabel.setIcon(new ImageIcon(Ausgabe5));
}
return jLabel;
}
public BDEPortal() {
super("BDE-Portal1");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(ClassNotFoundException cnfe) {}
catch(InstantiationException ie) {}
catch(IllegalAccessException iae) {}
catch(UnsupportedLookAndFeelException ulafe) {}
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setEnabled(true);
this.setName("BDE-Portal");
this.setLocation(5, 5);
this.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
this.setSize(1024, 768);
try {
this.setContentPane(getJContentPane());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.setTitle("BDE-Portal");
this.setVisible(true);
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
* @throws IOException
*/
private javax.swing.JPanel getJContentPane() throws IOException {
if(jContentPane == null) {
initClock=new JLabel();
initClock.setPreferredSize(new java.awt.Dimension(100,25));
initClock.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 18));
initClock.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
initClock.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
FlowLayout flowLayout1 = new FlowLayout();
jContentPane = new javax.swing.JPanel();
jContentPane.setLayout(flowLayout1);
flowLayout1.setHgap(500);
flowLayout1.setVgap(50);
jContentPane.setName("BDE Portal");
jContentPane.setPreferredSize(new java.awt.Dimension(1000,1000));
jContentPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
jContentPane.add(getjLabel(), null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(getJButton2(), null);
jContentPane.add(getJButton3(), null);
jContentPane.add(initClock());
}
return jContentPane;
}
public static void main(String[] args) {
BDEPortal P = null ;
}
}
Exception in thread "main"java.lang.NoClassDefFoundError: BDEPortal/Java
so darauf hin hab ich die Main rein gebastelt nun weis ich allerdings nich warum das Fenster nich auf geht. Wenn ich es unter Eclipse als Bean durch jage Funktioniert es ja.Allerdings weis ich nich wie ich in der Eingabeaufforderung aufferufen kann ich hab da viel arbeit rein gesteck das jetzt der 3 Tag an dem ich mich mit Java beschäftige eigentlich will ich nur wissen,was in die Main rein muss damit der Frame aufgeht!!!!Eigentlich hab ich immer gedacht BDEPortal() also der Konstruktor erledigt das aber naja was muss ich also nun noch in die Main schreiben??
mfg da KOKser
Edit von L-ectron-X: Titel angepasst.