Salve. Avrei un problema: praticamente non riesco ad eseguire un file JAR che ho creato...
Ho provato ad eseguire il JAR da console e mi da questi errori:
Come è possibile notare si riferisce a due specifiche righe del mio sorgente:
Ma se io eseguo il file .class principale da ms-dos, il programma funziona perfettamente... quindi, cosa c'è di sbagliato?? o_O Vi prego help mecodice:import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Pic extends JFrame { private JButton next; private JButton back; private JLabel label; private String[] names = new String[3]; private Icon[] pics = new Icon[3]; private int i; public Pic() { super("My Java Window"); setSize(370,245); setResizable(false); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout()); for (i=0;i<3;i++) { names[i] = "pic"+i+".jpg"; } for (i=0;i<3;i++) { riga 28: pics[i] = new ImageIcon(getClass().getResource(names[i])); } i = 0; back = new JButton("Indietro"); back.setToolTipText("Immagine precedente"); add(back); label = new JLabel(pics[0]); add(label); next = new JButton("Avanti"); next.setToolTipText("Immagine successiva"); add(next); ButtonHandler handler = new ButtonHandler(); next.addActionListener(handler); back.addActionListener(handler); setVisible(true); } private class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent event) { if (event.getSource() == back) { if (i > 0) { i--; label.setIcon(pics[i]); } else if (i == 0) { i = 2; label.setIcon(pics[i]); } } else if (event.getSource() == next) { if (i < 2) { i++; label.setIcon(pics[i]); } else if (i == 2) { i = 0; label.setIcon(pics[i]); } } } } public static void main(String[] args) { //riga 83: new Pic(); } }![]()


Rispondi quotando