# im JAR läufts nicht :( hilfe



## needJavaProz (18. Aug 2008)

Hallo zusammen,

Ich hab ein Problem, dessen Lösung "hoffentlich" ganz einfach ist. 

Tool:
So ein ding mit einem billigen GUI und berechnungskäse in einem separaten Thread. 


Wenn ich das im eclipse laufen lasse funktionierts die execution springt in den anderen Thread und rechnet. Sobald ich das Jar generiere (über export eclipse) und es executable mache geh ich zum Desktop und klicke zweimal. 

--> GUI erscheint wunderbar. Doch sobald ich auf Button "generate" klicke passiert nichts, keine berechnung. 

Gibts da irgendwas das man wissen sollte ?

danke und Gruss
Thomas




hier ist der code des GUI teils.. (wep)

- 




```
package entry;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.LayoutManager;
import java.awt.event.*;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.awt.Toolkit;


import javax.swing.*;
import javax.swing.border.Border;

public class frameit extends JFrame implements ActionListener {
	
	String dirSave;
	public static final String DIRECTORY = "C:\\Basefolder/datatest/";
	JTextField JTField;
	
	frameit fi; 
	JPanel JP;
	private static void staticcreateGUI() {
		frameit fi = new frameit();
		fi.createGUI();
		
	}

	
	private void createGUI() {
		
//		frame generieren
		fi = new frameit();
		fi.setTitle("Fee calculation");
	
//		menu bar
		JMenuBar JM = new JMenuBar();
		JM.setOpaque(true);
		JM.setPreferredSize(new Dimension(200,25));
		JMenu menu = new JMenu("Files");
		JM.add(menu);
		
//		start files panel		
		JP = new JPanel();
		JP.setMaximumSize(new Dimension(410,510));
		FlowLayout LM = new FlowLayout();
		LM.setHgap(1);
		LM.setVgap(1);
		JP.setLayout(LM);
		JP.setPreferredSize(new Dimension(420,450));
		JTField = new JTextField();
		JTField.setText(DIRECTORY);
		readDir();
		Border compoundBdr = createBorder("Files");
		JP.setBorder(compoundBdr);	
		
//		start directory panel		
		Border dirBrd = createBorder("Directory");
		JPanel JPdir = new JPanel();
		JPdir.setPreferredSize(new Dimension(420, 60));
		JPdir.setBorder(dirBrd);
		
		
		JPdir.add(JTField);
		JTField.setPreferredSize(new Dimension(233,20));
		JTField.setText(DIRECTORY);
		dirSave = DIRECTORY;
		GridBagLayout GBL = new GridBagLayout();
		JPdir.setLayout(GBL);
		GridBagConstraints c = new GridBagConstraints();
		c.weightx = 1;
		c.gridwidth = 1;   //2 columns wide
		c.gridy = 2;   	
		c.anchor = GridBagConstraints.FIRST_LINE_START;
		JPdir.add(JTField, c);	
		JButton JBrefresh = new JButton("Refresh");
		c.anchor = GridBagConstraints.FIRST_LINE_END;
		JBrefresh.setPreferredSize(new Dimension(100,20));
		
		JBrefresh.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				JButton JPmod = (JButton) evt.getSource();
				JPanel JPdir = (JPanel) JPmod.getParent();
				JTextField JTF = (JTextField) JPdir.getComponent(0);
				String directory  = JTF.getText();
				dirSave = directory;
				JPanel JPbig = (JPanel) JPdir.getParent();
				JPanel JPtoRefresh = (JPanel) JPbig.getComponent(0);
				JPtoRefresh.removeAll();
				dirPanel dP = new dirPanel(JPtoRefresh, directory);
				JPtoRefresh.repaint();
				fi.pack();	
			}
		});
		
		JPdir.add(JBrefresh, c);
//		start generate Panel		
		JPanel JPgen = new JPanel();
		Dimension dm = new Dimension(100,20);
		
		JPgen.setPreferredSize(new Dimension(420,50));
		JButton CB = new JButton("Calculate");
		CB.setPreferredSize(dm);
		CB.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt)  {		
				doThread dT = new doThread(dirSave);
				dT.start();
				doThread.yield();
				System.out.println("bla");	
			}
		});
		
		
		JPgen.setLayout(new GridBagLayout());
//		GridBagConstraints c = new GridBagConstraints();
		c.gridx = 1;
		c.anchor = GridBagConstraints.PAGE_START;
		c.weightx = 1;
		c.gridwidth = 1;   //2 columns wide
		c.gridy = 2;       //third row
		Insets Is = new Insets(0,60,0,0);
		Insets Is2 = new Insets(0,0,0,10);
		c.insets = Is;
				
		JPgen.add(CB, c);
		JButton JBcancel = new JButton("Cancel");
		JBcancel.setPreferredSize(dm);
		
		JBcancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				fi.setVisible(false);
				fi.dispose();
			}
		});
		
		
		c.anchor = GridBagConstraints.FIRST_LINE_END;
		c.insets = Is2;
		JPgen.add(JBcancel, c);
		
		
//		start consolidated panel
		JPanel JP2 = new JPanel();
		JP2.setPreferredSize(new Dimension(430, 580));
		JP2.add(JP);
		JP2.add(JPdir);
		JP2.add(JPgen);
	
		fi.add(JP2);
		fi.pack();
		fi.setDefaultCloseOperation(EXIT_ON_CLOSE);
		fi.setVisible(true);
		
	}
	
	private void doClose(int i) {
		this.setVisible(false);
	}


	public void addit(Component c) {
		this.add(c);
	}
	
	private static Border createBorder(String title) {	
		Border titledBdr = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title); 
		Border emptyBdr  = BorderFactory.createEmptyBorder(5,5,5,5);
		Border compoundBdr=BorderFactory.createCompoundBorder(titledBdr, emptyBdr);
		return compoundBdr;
	}
	
	
	public static void main(String args[]) {	
		javax.swing.SwingUtilities.invokeLater(new Runnable() { 
			public void run() {
				staticcreateGUI();
			}
		});
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
			Toolkit.getDefaultToolkit().beep();
	}
	
	private void readDir() {
		FlowLayout LM = new FlowLayout();
		LM.setHgap(1);
		LM.setVgap(1);
		JPanel JPdet = new JPanel();
		JPdet.setLayout(LM);
		JLabel JLname = new  JLabel("filename");
		Font font = JLname.getFont().deriveFont(Font.ROMAN_BASELINE);
		JLname.setPreferredSize(new Dimension(300,15));
		JLabel JLtime = new JLabel("modified date");
		
		JLtime.setPreferredSize(new Dimension(100,15));
		JPdet.add(JLname);
		JPdet.add(JLtime);
		
		Border brd = BorderFactory.createEmptyBorder(0, 0, 5, 0);
		Border brdEtch = BorderFactory.createEtchedBorder();
		Border brdComp = BorderFactory.createCompoundBorder(brdEtch, brd);

		
//		JPdet.setBorder(brdComp);
		JP.add(JPdet);
	
		
//		File f = new File(JTField.getText());
		File f = new File(DIRECTORY);
		File[] files = f.listFiles();
		System.out.println("bjalkdfjasklfjasdkldfjasdkljf");
		for (File fl : files) {
			if (!fl.isDirectory()) {
//				System.out.print(fl.getName());
				Date d = new Date(fl.lastModified());
				SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
				df.setTimeZone(TimeZone.getDefault());
//				System.out.print(df.format(d));
				JPdet = new JPanel();				
				JLname = new  JLabel(fl.getName());
				JLname.setPreferredSize(new Dimension(300,15));
				JLname.setFont(font);
				JLtime = new JLabel(df.format(d));
				JLtime.setPreferredSize(new Dimension(100,15));
				JLtime.setFont(font);
				JPdet.setLayout(LM);
				JPdet.add(JLname);
				JPdet.add(JLtime);
				JP.add(JPdet);		
			}
		}
	}



/*	public void run() {
		try {
			ProjectBase PB = new ProjectBase(dirSave);
			PB.execute();
		} catch (IOException e) {		
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}*/
}


class dirPanel  {	
		
	private String directory;
	JPanel JP;
	public dirPanel(JPanel J, String dir) {
		JP = J;
		directory = dir;
		this.insertData();
		JP.repaint();
	}
	
	
	public void actualize() {
		JP.repaint();
	}

	void insertData() {
		FlowLayout LM = new FlowLayout();
		LM.setHgap(1);
		LM.setVgap(1);
		JPanel JPdet = new JPanel();
		JPdet.setLayout(LM);
		JLabel JLname = new  JLabel("filename");
		Font font = JLname.getFont().deriveFont(Font.ROMAN_BASELINE);
		JLname.setPreferredSize(new Dimension(300,15));
		JLabel JLtime = new JLabel("modified date");
		
		JLtime.setPreferredSize(new Dimension(100,15));
		JPdet.add(JLname);
		JPdet.add(JLtime);
		
		Border brd = BorderFactory.createEmptyBorder(0, 0, 5, 0);
		Border brdEtch = BorderFactory.createEtchedBorder();
		Border brdComp = BorderFactory.createCompoundBorder(brdEtch, brd);

		
//		JPdet.setBorder(brdComp);
		JP.add(JPdet);
		
		
//		File f = new File(JTField.getText());
		File f = new File(directory);
		File[] files = f.listFiles();
		System.out.println("bjalkdfjasklfjasdkldfjasdkljf");
		for (File fl : files) {
			if (!fl.isDirectory()) {
//				System.out.print(fl.getName());
				Date d = new Date(fl.lastModified());
				SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
				df.setTimeZone(TimeZone.getDefault());
//				System.out.print(df.format(d));
				JPdet = new JPanel();				
				JLname = new  JLabel(fl.getName());
				JLname.setPreferredSize(new Dimension(300,15));
				JLname.setFont(font);
				JLtime = new JLabel(df.format(d));
				JLtime.setPreferredSize(new Dimension(100,15));
				JLtime.setFont(font);
				JPdet.setLayout(LM);
				JPdet.add(JLname);
				JPdet.add(JLtime);
				JP.add(JPdet);		
			}
		}
	}
}
	


class doThread extends Thread {
	
	String dir; 
	public doThread(String s) {
		dir = s;
	}
	
	public void run() {
		try {
			ProjectBase PB = new ProjectBase(dir);
			PB.execute();
		} catch (IOException e) {		
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
```


----------



## maki (18. Aug 2008)

Die Fehlermeldungen siehst du eben nur wenn du die jar von der Console ausführst.


----------



## needJavaProz (19. Aug 2008)

jo blööde  :autsch:  :bahnhof:  naja dafür gehts jetzt 

 :wink:


----------

