I keep getting NoClassDefFoundError so I cannot check if the rest of my program works. It works on the school computers but it does not at my house. I set up the path and classpath variables how my teacher told me for derby but it still will not work, any help you can give will be appreciated.

import java.sql.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class SQLTest{
	public static void main (String args[]) throws SQLException, IOException, ClassNotFoundException
	{
		Connection connection = getConnection();
		SQLFrame frame = new SQLFrame(connection);
		frame.setVisible(true);
	}
	public static Connection getConnection() throws SQLException, IOException, ClassNotFoundException
		{
			Properties props = new Properties();
			FileInputStream in = new FileInputStream("databaseRevised.properties");
			props.load(in);
			in.close();
			String drivers = props.getProperty("jdbc.drivers");
			if (drivers != null) System.setProperty("jdbc.drivers", drivers);
			String url = props.getProperty("jdbc.url");
			String username = props.getProperty("jdbc.username");
			String password = props.getProperty("jdbc.password");
			Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
			return DriverManager.getConnection(url, username, password);
   }
}
class SQLFrame extends JFrame{
	private Connection connection;
	private JTable table = new JTable();
	private JTextArea text = new JTextArea();
	private String query;
	public SQLFrame(Connection c)
	{
		connection = c;
		setSize(400, 600);
		JButton enter = new JButton("Enter Query");
		enter.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e)
			{
				try{
				query = text.getText();
				update();
				}catch(SQLException f){f.printStackTrace();}
			}
		});
		JPanel panelOne = new JPanel();
		JPanel panelTwo = new JPanel();
		panelOne.add(text);
		panelTwo.add(enter);
		this.setLayout(new BorderLayout());
		this.add(panelOne, BorderLayout.NORTH);
		this.add(panelTwo, BorderLayout.CENTER);
		this.add(new JScrollPane(table), BorderLayout.SOUTH);
	}
	public void update() throws SQLException
	{
		Statement statement = connection.createStatement();
		ResultSet results = statement.executeQuery(query);
		ResultSetMetaData metaData = results.getMetaData();
		results.last();
		int rowNum = results.getRow();
		Vector columnNames = new Vector();
		for(int i = 1; i <= metaData.getColumnCount(); i++)
		{
			columnNames.add(metaData.getColumnName(i));
		}
		Vector rowData = new Vector();
		for(int i = 1; i <= rowNum; i++)
		{
			Vector row = new Vector();
			results.absolute(i);
			for(int j = 1; j <= metaData.getColumnCount(); j++)
			{
				row.add(results.getObject(j));
			}
			rowData.add(row);
		}
		table = new JTable(rowData, columnNames);
		this.add(new JScrollPane(table), BorderLayout.SOUTH);
	}
}

are you running this on command line... if yes, then tell me what all you are writing thr

I think u are running on command line only.
follow these steps:
1. browse till ur current directory. In my case java file is in C:\workspace\TestProj\src, so cd till this directory
cd C:\workspace\TestProj\src
2. set the classpath, whereever jdk is installed
set path=%path%.;C:\Program Files\Java\jdk1.5.0_09\bin
3. compile class
javac SQLTest.java
4. run it
java -classpath . SQLTest

This article has been dead for over six months. Start a new discussion instead.