Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 17
  1. #1
    Utente di HTML.it L'avatar di pgm
    Registrato dal
    Apr 2002
    Messaggi
    1,281

    [Java] Eccezione in java.lang

    ciao!

    vorrei sapere cosa identifica questo errore:

    Exception in thread "main" java.lang.NoClassDefFoundError: nome_appl.

    Grazie

    pgm

  2. #2
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    il nome del file č diverso da quello della classe oppure nella classe manca il main :adhone:

  3. #3
    Utente di HTML.it L'avatar di pgm
    Registrato dal
    Apr 2002
    Messaggi
    1,281
    grazie flotd per il consiglio, ma ho provato e tutto č in ordine, il main c'č e il nome della classe č uguale al nome del file

    pgm

  4. #4
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    posta il codice della classe

  5. #5
    Utente di HTML.it L'avatar di pgm
    Registrato dal
    Apr 2002
    Messaggi
    1,281
    Questo č il codice. Scusami in anticipo se ci sono madornali errori...Considera che č da una settimana che programmo in java.
    Il programma deve prendere il valore di un campo in input, formattarlo ed inserirlo in uno stringone, il tutto verrā passato a cobol (aimč). Questo programma č una prova, infatti voglio scrivere lo stringone su un file per vedere cosa ne esce.

    Ciao pgm

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;

    import java.io.*;

    public class pgm extends JFrame{
    public static int WIDTH = 350;
    public static int HEIGHT = 230;
    public static String TITLE = "pgm";

    Container frameContainer;

    JMenuBar barraMenu = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenuItem fileExit = new JMenuItem("Esci");

    JTextField testo = new JTextField();
    JTextField testo1 = new JTextField();
    JTextField testo2 = new JTextField();

    JButton opButton = new JButton("Go");

    public pgm() {
    super(TITLE);
    buildGUI();
    setSize(WIDTH,HEIGHT);
    setupEventHandlers();
    show();
    }

    void buildGUI(){
    setupMenuBar();
    layoutComponents();
    }

    void setupMenuBar(){
    fileMenu.add(fileExit);
    barraMenu.add(fileMenu);
    setJMenuBar(barraMenu);
    }

    public void layoutComponents(){
    frameContainer = getContentPane();
    frameContainer.setLayout(null);
    testo.setBounds(10,10,120,18);
    testo1.setBounds(10,32,120,18);
    testo2.setBounds(10,54,120,18);
    opButton.setBounds(10,100,50,20);
    frameContainer.add(testo);
    frameContainer.add(testo1);
    frameContainer.add(testo2);
    frameContainer.add(opButton);
    }

    void setupEventHandlers() {
    addWindowListener(new WindowHandler());
    opButton.addActionListener(new ButtonHandler());
    fileExit.addActionListener(new MenuItemHandler());
    }

    class ButtonHandler implements ActionListener{
    public void actionPerformed(ActionEvent e){
    String s = e.getActionCommand();
    if(s.equals("Go")){
    stampaStringa();
    }
    }
    }

    class MenuItemHandler implements ActionListener{
    public void actionPerformed(ActionEvent d){
    String t = d.getActionCommand();
    if(t.equals("Esci")){
    System.exit(0);
    }
    }
    }

    public void stampaStringa(){

    String tutto = testo.getText().toUpperCase().trim(); // as 30

    try{
    transfert(tutto);
    }catch(Exception e){
    //System.out.println(e.toString());
    }

    }

    public StringBuffer transfert(String tutto) throws IOException {

    StringBuffer RWLXLB = new StringBuffer();

    StringBuffer w = new StringBuffer(tutto);

    base(RWLXLB,5,1);
    base(RWLXLB,5,1);
    base(RWLXLB,5,1);
    base(RWLXLB,10,0);
    base(RWLXLB,4,0);
    base(RWLXLB,16,1);
    base(RWLXLB,16,1);
    base(RWLXLB,3,0);
    base(RWLXLB,5,1);
    base(RWLXLB,4,0);
    base(RWLXLB,4,0);
    base(RWLXLB,3,0);
    base(RWLXLB,70,0);

    base(RWLXLB,8,0);
    base(RWLXLB,8,0);
    base(RWLXLB,30,0);
    base(RWLXLB,5,1);
    base(RWLXLB,1,0);
    base(RWLXLB,1,0);
    base(RWLXLB,120,0);
    base(RWLXLB,3,0);
    base(RWLXLB,3,0);
    base(RWLXLB,30,0);
    base(RWLXLB,30,0);
    base(RWLXLB,1,0);
    base(RWLXLB,2,0);
    base(RWLXLB,10,1);
    base(RWLXLB,136,0);
    base(RWLXLB,30,0);
    base(RWLXLB,4,0);
    base(RWLXLB,2,1);
    base(RWLXLB,6,0);
    base(RWLXLB,8,0);
    base(RWLXLB,30,0);
    base(RWLXLB,32,0);

    RWLXLB.append("TRA");
    base(RWLXLB, 3,0);
    base(RWLXLB, 3,0);
    base(RWLXLB, 33,0);

    RWLXLB.append("DTU");
    base(RWLXLB, 3,0);
    base(RWLXLB, 44,0);
    RWLXLB.append("O");
    RWLXLB.append("S");
    base(RWLXLB, 48,0);
    RWLXLB.append("999");

    RWLXLB.append(w); //campo di testo
    int ln = w.length();

    for (int i=ln; i<=30; i++)
    RWLXLB.append(" ");

    base(RWLXLB, 18,1);
    base(RWLXLB, 69,0);
    base(RWLXLB, 1,0);
    base(RWLXLB, 99,0);
    base(RWLXLB, 3,0);
    base(RWLXLB, 30,0);
    base(RWLXLB, 9,1);

    base(RWLXLB, 9,0);
    base(RWLXLB,50,0);
    base(RWLXLB,1,0);
    base(RWLXLB,3,1);
    base(RWLXLB,5,1);
    base(RWLXLB,3,1);
    base(RWLXLB,50,0);
    base(RWLXLB,30,0);
    base(RWLXLB,18,1);
    base(RWLXLB,3,1);
    base(RWLXLB,5,1);
    base(RWLXLB,1,0);
    base(RWLXLB,3,0);
    base(RWLXLB,5,0);
    base(RWLXLB,5,1);
    base(RWLXLB,5,1);
    base(RWLXLB,5,1);
    base(RWLXLB,10,0);
    base(RWLXLB,4,0);
    base(RWLXLB,16,0);
    base(RWLXLB,16,0);
    base(RWLXLB,16,0);
    base(RWLXLB,1,0);
    base(RWLXLB,53,0);
    base(RWLXLB,3,0);
    base(RWLXLB,30,0);
    base(RWLXLB,9,1);
    base(RWLXLB,50,0);
    base(RWLXLB,50,0);
    base(RWLXLB,1,0);
    base(RWLXLB,3,1);
    base(RWLXLB,5,1);
    base(RWLXLB,3,1);
    base(RWLXLB,50,0);
    base(RWLXLB,30,0);
    base(RWLXLB,18,0);
    base(RWLXLB,3,1);
    base(RWLXLB,5,1);
    base(RWLXLB,1,0);
    base(RWLXLB,3,0);
    base(RWLXLB,5,0);
    base(RWLXLB,5,1);
    base(RWLXLB,5,1);
    base(RWLXLB,5,1);
    base(RWLXLB,10,0);
    base(RWLXLB,4,0);
    base(RWLXLB,16,0);
    base(RWLXLB,16,0);
    base(RWLXLB,16,0);
    base(RWLXLB,1,0);
    base(RWLXLB,53,0);

    base(RWLXLB,200,0);

    FileOutputStream outStream = new FileOutputStream("prova.txt");
    for(int i=0; i<RWLXLB.length(); ++i)
    outStream.write(RWLXLB.charAt(i));
    outStream.close();

    StringBuffer s = new StringBuffer(RWLXLB.toString());
    return s;

    }

    public void base(StringBuffer arealnk, int times, int tp){

    for( int i=0; i < times; ++i)
    arealnk.append(" ");

    }

    public static void main(String[] args) {
    pgm app = new pgm();
    }

    public class WindowHandler extends WindowAdapter{
    public void windowClosing(WindowEvent e){
    System.exit(0);
    }
    }
    }

  6. #6
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    pare a posto

    questo deve stare in un file pgm.java che compili con javac pgm.java e apri con java pgm

  7. #7
    Utente di HTML.it L'avatar di pgm
    Registrato dal
    Apr 2002
    Messaggi
    1,281
    La compilazione di pgm.java va a buon fine, ma l'esecuzione (java pgm)
    mi da l'errore che ho riportato.
    Non so cosa fare...fra poco spacco il computer compreso il manuale di java (scherzo). se mi dai qualche idea ti offro 7 birre dovunque tu sia.
    grazie per la disponibilitā.

    pgm

  8. #8
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    l'ho compilato, col jdk 1.4 e win2000 funziona
    prova a dare il percorso completo del compilatore es
    c:\> c:\jdk1.4\bin\java pgm

  9. #9
    Utente di HTML.it L'avatar di pgm
    Registrato dal
    Apr 2002
    Messaggi
    1,281
    Vuoi dire cosė:
    set path=%path%C:\jdk1.2.2\bin?

    pgm

  10. #10
    Utente di HTML.it L'avatar di floyd
    Registrato dal
    Apr 2001
    Messaggi
    3,837
    dal prompt dos devi scrivere quello che ho postato

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.