I get the message Exception in thread "main" java.lang.StackOverflowError

I'm trying to make a program for my class and when I run the program I get the error Exception in thread "main" java.lang.StackOverflowError, I have looked up what it means and I don't see where in my program would be giving the error, can someone please help me, here is the program
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
// This visual application allows users to "shop" for items,
// maintaining a "shopping cart" of items purchased so far.
public class ShoppingApp extends JFrame
implements ActionListener {
private JButton addButton, // Add item to cart
removeButton; // Remove item from cart
private JTextArea itemsArea, // Where list of items for sale displayed
cartArea; // Where shopping cart displayed
private JTextField itemField, // Where name of item entered
messageField; // Status messages displayed
private ShoppingCart cart; // Reference to support object representing
// Shopping cart (that is, the business logic)
String itemEntered;
public ShoppingApp() {
// This array of items is used to set up the cart
String[] items = new String[5];
items[0] = "Computer";
items[1] = "Monitor";
items[2] = "Printer";
items[3] = "Scanner";
items[4] = "Camera";
// Construct the shopping cart support object
cart = new ShoppingCart(items);
// Contruct visual components
addButton = new JButton("ADD");
removeButton = new JButton("REMOVE");
itemsArea = new JTextArea(6, 8);
cartArea = new JTextArea(6, 20);
itemField = new JTextField(12);
messageField = new JTextField(20);
// Listen for events on buttons
addButton.addActionListener(this);
removeButton.addActionListener(this);
// The list of items is not editable, and is in light grey (to
// make it distinct from the cart area -- this would be done
// better by using the BorderFactory class).
itemsArea.setEditable(false);
itemsArea.setBackground(Color.lightGray);
cartArea.setEditable(false);
// Write the list of items into the itemsArea
itemsArea.setText("Items for sale:");
for (int i = 0; i < items.length; i++)
itemsArea.append("\n" + items);
// Write the initial state of the cart into the cartArea
cartArea.setText("No items in cart");
// Construct layouts and add components
JPanel mainPanel = new JPanel(new BorderLayout());
getContentPane().add(mainPanel);
JPanel controlPanel = new JPanel(new GridLayout(1, 4));
controlPanel.add(new JLabel("Item: ", JLabel.RIGHT));
controlPanel.add(itemField);
controlPanel.add(addButton);
controlPanel.add(removeButton);
mainPanel.add(controlPanel, "North");
mainPanel.add(itemsArea, "West");
mainPanel.add(cartArea, "Center");
mainPanel.add(messageField, "South");
public void actionPerformed(ActionEvent e)
itemEntered=itemField.getText();
if (addButton==e.getSource())
cart.addComputer();
     messageField.setText("Computer added to the shopping cart");
public static void main(String[] args) {
ShoppingApp s = new ShoppingApp();
s.setSize(360, 180);
s.show();
this is a seperate file called ShoppingCart
public class ShoppingCart extends ShoppingApp
private String[] items;
private int[] quantity;
public ShoppingCart (String[] inputitems)
super();
items=inputitems;
quantity=new int[items.length];
public void addComputer()
int x;
for (x=0; "computer".equals(itemEntered); x++)
     items[x]="computer";
please somebody help me, this thing is due tomorrow I need help asap!

First, whenever you post, there is a link for Formatting Help. This link takes you to here: http://forum.java.sun.com/features.jsp#Formatting and tells you how to use the code and /code tags so any code you post will be easily readable.
Your problem is this: ShoppingApp has a ShoppingCart and ShoppingCart is a ShoppingApp - that is ShoppingCart extends ShoppintApp. You are saying that ShoppingCart is a ShoppingApp - which probably doesn't make sense. But the problem is a child class always calls one of its parent's constructors. So when you create a ShoppingApp, the ShoppingApp constructor tries to create a ShoppingCart. The ShoppingCart calls its superclass constructor, which tries to create a ShoppingCart, which calls its superclass constructor, which tries to create a ShoppingCart, which...
It seems like ShoppingCart should not extend ShoppingApp.

Similar Messages

  • Exception in thread "main" java.lang.StackOverflowError

    HI I am getting this error and I am not sure why... When I debug it goes to when I create a buttonlistener, then skipped over it and it went like 5 lines before. Which is odd.
    Here is my code:
    package calcGPA;
    public class GPA {
         public static void main(String[] args) {
              new GPACalculator();     
    package calcGPA;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    //import java.text.DecimalFormat;
    public class GPACalculator extends JFrame
        char letterGrade;
        double credits,
               creditGrade,
               GPA,
               points = 0.0,
               totalCredits = 0.0;
        private JButton calcButton,
                        clearButton;
        private JLabel gradeDisplay,
                       creditsDisplay;
         protected JLabel messageDisplay;
        protected JTextField gradeField;
         protected JTextField creditsField;
        private JPanel panelTop,
                       panelMid,
                       panelLow;
        private int WINDOW_WIDTH = 300,
                    WINDOW_HEIGHT = 200;
        boolean result = true,
                cResult = true;
        String display;
        public GPACalculator(){
            setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setLayout(new GridLayout(3, 1));
            gradeDisplay = new JLabel("Grade");
            gradeField = new JTextField(4);
            creditsDisplay = new JLabel("Credits");
            creditsField = new JTextField(4);
            calcButton = new JButton("Calculate");
            clearButton = new JButton("Clear");
             ///////////////////////////// I think this is where my error comes in?
            ButtonListener test = new ButtonListener();
            calcButton.addActionListener(test);
            clearButton.addActionListener(new ButtonListener());
            panelTop = new JPanel();
            panelTop.add(gradeDisplay);
            panelTop.add(gradeField);
            panelTop.add(creditsDisplay);
            panelTop.add(creditsField);
            messageDisplay = new JLabel(display);
            panelMid = new JPanel();
            panelMid.add(messageDisplay);       
            panelLow = new JPanel();
            panelLow.add(calcButton);
            panelLow.add(clearButton);   
            add(panelTop);
            add(panelMid);
            add(panelLow);
            setVisible(true);
            letterGrade = ' ';   
            credits = 0;   
        public boolean setLetterGrade(char lG)
            switch (lG)
                    case 'a':             
                    case 'A':
                        letterGrade = 'A';
                        result = true;
                        break;
                    case 'b':
                    case 'B':
                        letterGrade = 'B';
                        result = true;
                        break;
                    case 'c':
                    case 'C':
                        letterGrade = 'C';
                        result = true;
                        break;
                    case 'd':
                    case 'D':
                        letterGrade = 'D';
                        result = true;
                        break;
                    case 'f':
                    case 'F':
                        letterGrade = 'F';
                        result = true;
                        break;
                    default:
                        result = false;
                        break;
            return result;       
        public boolean setCredits(double cr)
            boolean result = true;
            if (cr < .25 || cr > 6)
                cResult = false;
            else
                cResult = true;
            return cResult;                       
        public char getLetterGrade()
            setLetterGrade(letterGrade);
            return letterGrade;               
        public double getCredits()
            setCredits(credits);
            return credits;
        public double getCreditGrade(char letterGrade)
                if (letterGrade == 'A')
                    creditGrade = 4.0;
                else if (letterGrade == 'B')
                    creditGrade = 3.0;
                else if (letterGrade == 'C')
                    creditGrade = 2.0;
                else if (letterGrade == 'D')
                    creditGrade = 1.0;
                else if (letterGrade == 'F')
                    creditGrade = 0.0;
                else
                    result = false;
                return creditGrade;   
        public double calcGPA()
            points += getCreditGrade(letterGrade) * credits;
            totalCredits += credits;
            GPA = points / totalCredits;
            return GPA;   
    package calcGPA;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class ButtonListener extends GPACalculator implements ActionListener
         public ButtonListener(){
        public void actionPerformed(ActionEvent a)
            String readGrade,
                   readCredits,
                   buttonAction = a.getActionCommand();
            if (buttonAction == "Calculate")
                readGrade = gradeField.getText();
                letterGrade = readGrade.charAt(0);
                setLetterGrade(letterGrade);
                if (result == false)
                    display = "Letter grade must be a, b, c, d, or f.";
                    messageDisplay.setText(display);
                try{
                     readCredits = creditsField.getText();
                     credits = Double.parseDouble(readCredits);
                     setCredits(credits);
                     if (cResult == false){
                          display = "Credits must be between .25 and 6 inclusive.";
                          messageDisplay.setText(display);
                catch (NumberFormatException nfe){
                    display = "Credits should be a number.";
                    messageDisplay.setText(display);
                    result = false;
                if (result == true && cResult == true){
                    calcGPA();               
                    messageDisplay.setText("New GPA is: " +GPA);
            if (buttonAction == "Clear"){
                points = 0.0;
                totalCredits = 0.0;
                gradeField.setText("");
                creditsField.setText("");
                display = "";
                messageDisplay.setText(display);
    }Sorry for the length, and thanks for anyhelp!
    Edited by: RandellK on Aug 4, 2010 7:58 PM

    Why on earth does ButtonListener extend GPACalculator? Is ButtonListener a special type of GPACalculator? No.
    You construct a ButtonListener in the constructor of GPACalculator. The superclass constructor constructs a ButtonListener ... ad infinitum .. and the stack blows up.
    In general, never attempt to construct an instance of a subclass in the constructor of any superclass. It absolutely guarantees a StackOverflowError.
    Additionally, never use == for comparing Strings or any other objects (except in the rare case where you need identity comparison). Use the .equals(...) method.
    db
    Edited by: DarrylBurke -- Dang it, late again!

  • Exception in thread "main" java.lang.NoClassDefFoundError: Helloworld

    Hi Java Experts,
    I am at a lost to how Java searches for all the classes when running a program. Below are the following steps I have taken to try a simple basic HelloWorld.java program on the command prompt on Windows XP (SP2) platform:
    ( i ) Installed both jdk1.5.0_09 and Netbeans IDE 5.0 and working properly.
    ( ii ) The source file is located in F:\Documents and Settings\abc\HeadFirstDesignPattern\src\ch11 and the compiled file is in F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes\ch11 which was compiled in Netbeans.
    ( iii ) No problem compiling & running this program in Netbeans.
    ( iv ) The RUN CLASSPATH in Netbeans is F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes.
    ( v ) No CLASSPATH variable has been set.
    ( vi ) The HelloWorld program looks like this:
    package ch11;
    public class HelloWorld {
    public static void main(String[] args) {
    System.out.println("Hello World!");
    ( vi ) Got the message
    "Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld"
    when running a combination of the following Java commands:
    ( a ) cd F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes
    ( b ) java HelloWorld, or
    java -cp . HelloWorld or java -cp "." HelloWorld, or
    java -cp F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes HelloWorld or "F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes" HelloWorld, or
    java -cp F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes;. HelloWorld or "F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes";. HelloWorld, or
    java -cp "F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes";. HelloWorld or "F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes";"." HelloWorld, or
    java -cp "F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes";. HelloWorld or "F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes";"." ch11\HelloWorld.
    It is the package location which is a subdirectory of F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes which caused Java not to find this program. I had no problem running it if the HelloWorld.java was moved one level up. ie from F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes\ch11 to F:\Documents and Settings\abc\HeadFirstDesignPattern\build\classes.
    I have written Java in the last year mostly on Netbeans without any problem running them.
    The reason for having to learn to run Java on the command line is so that I could add arguments to the program which I couldn't do in Netbeans just yet.
    I have gone through a lot of the articles from Java forums, Google searches but yet to have found a solution.
    Many thanks,
    Netbeans Fan

    I am getting the same problem when running the same program on a Fedora 4.0 (Redhat Linux 10) system, together with Netbeans 5.5 and JDK1.5.0_09. Again, I have no such problem when running the same program in Netbeans.
    Here are the steps that I have taken as follows:
    $ hostname
    spisu07.stvincents.com.au
    $ uname -a
    Linux spisu07.stvincents.com.au 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686
    $ pwd
    /home/dbi/HeadFirstDesignPattern/build/classes/ch11a
    $ cd ..
    $ pwd
    /home/dbi/HeadFirstDesignPattern/build/classes
    $ ls
    ch11a
    $ ls ch11a
    GumballMachine.class GumballMonitor.class NoQuarterState.class State.class
    GumballMachineRemote.class GumballMonitorTestDrive.class SoldOutState.class WinnerState.class
    GumballMachineTestDrive.class HasQuarterState.class SoldState.class
    $ java -cp . ch11a.GumballMachineTestDrive
    Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: ch11a.GumballMachineTestDrive
    at java.lang.VMClassLoader.transformException(java.lang.Class, java.lang.Throwable) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
    at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0)
    at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
    Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
    at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
    at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0)file:///usr/share/doc/HTML/index.html
    ...4 more
    $ echo $PATH
    /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/opt/netbeans-5.5/bin:/etc/alternatives/.:/opt/netbeans-5.5/bin:/opt/jdk1.5.0_09:/etc/alternatives/.
    $ echo $JAVA_HOME
    $ echo $CLASSPATH
    Any suggestions?
    Thanks,
    Henry

  • Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

    hi to all.
    iam getting this error: could any one give me the solution.
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    at DinosaursDataLoader.getData(DinosaursDataLoader.java:49)
    at DinosaursPack.load(DinosaursPack.java:22)
    at DinosaursPack.<init>(DinosaursPack.java:18)
    at myproject.main(myproject.java:17)
    import java.util.*;
    import java.io.*;
    import javax.swing.ImageIcon;
    public class Driver {
        public static void main (String[] args) {
              // create a Scanner and grab the data . . .
                 File f=new File("C:\\Users\\hariprasad koineni\\Desktop\\r.txt");// my text file containes 12 dinosuor card info
              Scanner scanner = null;
              try {
                    scanner = new Scanner(f);
              } catch (FileNotFoundException fnf) {
                    System.out.println(fnf.getMessage());
                    System.exit(0);
            // scan file line-by-line
              scanner.useDelimiter("------------------------------------------------------------------");
              int y=0;
              while (scanner.hasNext()) {
                String line = scanner.next().trim();
                System.out.println(line);
                String bits[]= new String[19];
                String[] bit = line.split("\n");       // Regex available since Java 5
                for(int j=0;j<=(bit.length-1);j++){
                        String[] bis = bit[j].split(":");
                        System.out.println(bis[0]);
                        String t=bis[1].trim();
                        bits[j]=t;
                        System.out.println(bits[j]);
                        System.out.println(j);
                String t = bits[0];                        // title
                String imgFileName = bits[1];          // image file name
                float  h = Float.parseFloat(bits[2]);    // height
                String  w = bits[3];    // weight
                String  l = bits[4];    // length
                int  kr = Integer.parseInt(bits[5]);    // killer rating
                String  i = bits[6];     // intelligence
                int  a = Integer.parseInt(bits[7]);     // age
                String df = bits[8];                      // dino file
                // create the image
               y++;
             System.out.println(line);
             System.out.println(y);
    }

    h_koineni wrote:
    sorry
    iam getting the error:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
    at Driver.main(Driver.java:38)So meaning this line cause the exception:
    String t=bis[1].trim(); // hard-coded int literal 1That happens because, in line 36,
    String[] bis = bit[j].split(":");What will happen if the delimiter ':' is not found? It will return an array with a size of 1, and at this time referencing index 1 is out of bound, remember that the upper bound of an array is its size-1. One workaround is to put a selection structure after line 36.
    if (bis != null && bis.length == 2) {
        String t=bis[1].trim();
        bits[j]=t;
    }Then, recompile your code and try again.

  • Exception in thread "main" java.lang.NoClassDefFoundError: TestInstallCreat

    I am working width demo's under sqlj in Oracle 8.1.7
    under windows 2000.
    Here is an example of my problem:
    C:\orawinnt\sqlj\demo>java TestInstallCreateTable
    Exception in thread "main" java.lang.NoClassDefFoundError: TestInstallCreateTable
    The program:
    C:\orawinnt\sqlj\demo>type TestInstallCreateTable.java
    import java.sql.*;
    import oracle.sqlj.runtime.Oracle;
    import sqlj.runtime.ref.DefaultContext;
    class TestInstallCreateTable {
    public static void main (String args[]) throws SQLException
    Connection conn=null;;
    PreparedStatement ps=null;
    /* if you're using a non-Oracle JDBC Driver, add a call here to
    DriverManager.registerDriver() to register your Driver
    // set the default connection to the URL, user, and password
    // specified in your connect.properties file
    Oracle.connect(TestInstallCreateTable.class, "connect.properties");
    conn = DefaultContext.getDefaultContext().getConnection();
    try {
    ps = conn.prepareStatement("DROP TABLE SALES");
    ps.executeUpdate();
    } catch (SQLException e) {
    // it'll throw an error of the table doesn't exist in many JDBC drivers
    try {
    ps = conn.prepareStatement(
    "CREATE TABLE SALES (" +
    "ITEM_NUMBER NUMBER, " +
    "ITEM_NAME CHAR(30), " +
    "SALES_DATE DATE, " +
    "COST NUMBER, " +
    "SALES_REP_NUMBER NUMBER, " +
    "SALES_REP_NAME CHAR(20))");
    ps.executeUpdate();
    System.out.println("SALES table created");
    } catch (SQLException se) {
    System.out.println("oops! can't create the sales table. error is:");
    se.printStackTrace();
    C:\orawinnt\sqlj\demo>
    C:\orawinnt\sqlj\demo>type connect.properties
    # Users should uncomment one of the following URLs or add their own.
    # (If using Thin, edit as appropriate.)
    sqlj.url=jdbc:oracle:thin:@172.22.50.117:1521:kemner
    #sqlj.url=jdbc:oracle:oci8:@
    #sqlj.url=jdbc:oracle:oci7:@
    #sqlj.url=kemner
    # User name and password here (edit to use different user/password)
    sqlj.user=scott
    sqlj.password=tiger
    Here comes my CLASSPATH:
    c:\jdk1.2.2\lib;c:\egneklasser;c:\orawinnt\bin;c:\orawinnt\sqlj\lib\translator.zip;c:\orawinnt\sqlj\lib\runtime12.zip;c:\orawinnt\jdbc\lib\classes12.zip;c:\orawinnt\jdbc\lib\nls_charset12.zip;c:\orawinnt\jdbc\lib\jndi.zip;c:\orawinnt\jdbc\lib\jta.zip
    Have anybody solutions of my problem?

    Sorry to steal this thread but I'm new here and don't know yet how to open new thread. I'm getting this error too. I'm at the very start of a book titled "Teach Yourself Java" and I'm trying execute the first example. I downloaded and installed Java at
    C:\Program Files\Java\jdk1.6.0_11\bin.
    I set up folder C:\Java Applications and put my first fiel in there titeld Example1.java
    Based an another thread here I went into Start | Control Panel | Ssystem | Advanced | Environment Variables and updated variable PATH by adding to the end of it ;C:\Program Files\Java\jdk1.6.0_11\bin.
    I can now navigate to C:\Java Applications and exeute javac Example1.java and it compiles OK but when I execute java Example1.java I get the error Exception in thread "main" java.lang.NoClassDefFoundError.
    I dont' know anything about the set CLASSPATH that is mentioned in this thread. Where does that go or is there something else I need?

  • Exception in thread "main" java.lang.NoClassDefFoundError: oracle/apex/APEX

    Hi All,
    Getting the above error when running the following export utility:
    $ java oracle/apex/APEXExport
    ABove error is thrown.
    I have looked at most blogs suggested by ML.
    Here are my env params:
    echo $CLASSPATH
    /u01/app/oracle/product/11.2.0/db_1/jdbc/lib/ojdbc5dms.jar
    ( No, i don't see any classes12.jar. The classes12.zip resides in oui folder. I tried that as well and it didnt work)
    echo $JAVA_HOME
    /usr/java/jdk1.7.0_02
    So for the heck of it, I tried:
    $ export CLASSPATH=.:${ORACLE_HOME}/jdbc/lib/classes12.zip
    and lo, I am able to at least summon this:
    $ java oracle/apex/APEXExport
    Usage APEXExport -db -user -password -applicationid -workspaceid -instance -skipExportDate -expSavedReports -debug
    -db: Database connect url in JDBC format
    -user: Database username
    -password : Database password
    -applicationid : ID for application to be exported
    -workspaceid : Workspace ID for which all applications to be exported
    -instance : Export all applications
    -skipExportDate : Exclude export date from application export files
    -expSavedReports: Export all user saved intera
    BUT: when invoking specific job, I get this:
    java oracle/apex/APEXExport -db hostname:1521:SID -user apex_030200 -password welcome123 -instance
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
    at oracle.apex.APEXExport.main(APEXExport.java:315)
    any ideas?

    Hello,
    I get a very similar error.
    Windows 7 Ultimate SP1
    Oracle XE 11.2
    Apex 4.1
    jdk 6u31-windows x64.exe (installed to C:\Program Files\Java\jdk1.6.0_31\.....)
    User Variable CLASSPATH = .\; C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar
    User Variable JAVA_HOME = C:\program files\java\jdk1.6.0_31\jre\bin
    User Variable ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server
    System Variable PATH = C:\oraclexe\app\oracle\product\11.2.0\server\bin;;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\11.0\DLLShared\;C:\Program Files (x86)\Pinnacle\Shared Files\;C:\Program Files (x86)\Pinnacle\Shared Files\Filter\;C:\Program Files (x86)\QuickTime\QTSystem\
    At the C:\apex\utilities directory I give the command:
    java oracle.apex.APEXExpress -db localhost:1521:XE -user SUSANNA -password skippy123 -expworkspace
    I get the error:
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle/apex/APEXExpress
    Caused by: java.lang.ClassNotFoundException: oracle.apex.APEXExpress
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doProvileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    Could not find the main class: oracle.apex.APEXExpress. Program will exit.

  • Exception in thread "main" java.lang.ClassNotFoundException

    I am trying to compile a very simple java program in windows vista, I am using jdk1.6.0_15:
    public class Success {
    public static void main (String [] args) {
    System.out.println ("hooray!");
    no problem with compilation, but I keep getting the following error message when I run java Success:
    Exception in thread "main" java.lang.ClassNotFoundException: Success
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged<Native Method>
    at java.net.URLClassLoader.findClass<URLClassLoader.java:188>
    at java.lang.ClassLoader.loadClass<ClassLoader.java:307>
    at sun.misc.Launcher$AppClassLoader.loadClass<Launcher.java:301>
    at java.lang.ClassLoader.loadClass<ClassLoader.java:252>
    at java.lang.ClassLoader.loadClassInternal<ClassLoader.java:320>
    Couldn’t find the main class: Success program will exit.
    Please help!!
    thanks
    Thomas

    the out put is:
    after running javac Success.java a Success.class file gets created
    when I run java Success cmd i get the following error message:
    Exception in thread "main" java.lang.ClassNotFoundException: Success
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged<Native Method>
    at java.net.URLClassLoader.findClass<URLClassLoader.java:188>
    at java.lang.ClassLoader.loadClass<ClassLoader.java:307>
    at sun.misc.Launcher$AppClassLoader.loadClass<Launcher.java:301>
    at java.lang.ClassLoader.loadClass<ClassLoader.java:252>
    at java.lang.ClassLoader.loadClassInternal<ClassLoader.java:320>
    Couldn’t find the main class: Success program will exit.
    thanks.

  • "Exception in thread "main" java.lang.NoClassDefFound Error" in XP

    I was creating programs just fine for awhile. Then, for some unknown reason, I start getting the runtime error message, "Exception in thread "main" java.lang.NoClassDefFound Error." I set my PATH in the following manner:
    Start | Control Panel | Performance and Maintenance | System | Advanced | Environment Variables | Use Variables for Owner | PATH | Edit | C:\j2sdk1.4.2_04;C:\j2sdk1.4.2_04\bin;C:\j2sdk1.4.2_04\jre\bin | Ok | Ok | Ok
    I then closed the dialog boxes and restarted my computer. I then tried to run a program that ran before, only to get the same runtime error! Can someone please help me???

    NoClassDefFoundError happens because the JVM cannot find some class from your program, not because the OS cannot find your JVM (PATH regulates the latter, but not the former). JVM looks up classes in directories (or JAR files) specified through the -classpath option, like "java -classpath c:\myclasses MyMainClass". Read the online doc for the "java" launcher for more info.

  • Exception in thread "main" java.lang.NoSuchMethodeError: main

    I'm trying to learn Java, but even the simple HelloWord won't run.
    It compiles fine with: javac HelloWorld.java
    But when I run the program with: java Helloworld or java -classpath . HelloWorld
    I always get the following error message: Exception in thread "main" java.lang.NoSuchMethodeError: main
    Path = ....;C:\j2sdk1.4.1\bin
    Classpath = C:\j2sdk1.4.1\lib\tools.jar;c:\j2sdk1.4.1\src.zip;c:\Java
    c:\Java is where I've stored HelloWorld.java.
    I'm using Java 2 SDK 1.4.1 on a Windows XP Pro platform.
    Here the simple code for HelloWorld:
    public class HelloWorld{
    public static void main(String[] args){
    System.out.println("Hello World!");
    Who out there can help me along. I want to learn Java, but if I can't even run the simplest application, it's hopeless.
    You can mail me: [email protected]
    or leave a message here.
    thx

    It should run with things as you've set them up. I copied, compiled and ran the program ok.
    Watch your capitalization; there is an error in your post (but maybe you just posted wrong):
    But when I run the program with: java Helloworld or java -classpath . HelloWorldSearch for another file that has the same name - but is an applet, without the main method; that is what the error is saying it found.
    Delete all the HelloWorld .java & .class files, recreate the program file, recompile and try running the new copy. There may be a non-visible error in the file.
    Make sure you run as follows:
    In the same directory as HelloWorld.java, enter "javac" - the program should print out a list of options, if not, set your PATH - see below.
    In the same directory as HelloWorld.java, enter "javac HelloWorld.java" and the javac compiler will create HelloWorld.class. If it was successful it will not give any messages. Check that the file is created.
    In the same directory as HelloWorld.java, enter "java -cp . HelloWorld" with the spaces and the period. The program will run.
    Here is additional information:
    The Path is a set of pointers that Windows uses to locate programs that you execute, like javac.exe and java.exe. This setting is explained here:
    http://java.sun.com/j2se/1.4/install-windows.html
    Scroll down to: 5. Update the PATH variable
    (you should have already done this as part of the s/w installation)
    The CLASSPATH is another set of pointers that is used by Java to find the files that you create and want compiled and/or run. This setting is explained here:
    Setting the Classpath:
    http://java.sun.com/j2se/1.4/docs/tooldocs/windows/classpath.html
    [NOTE: always start your classpath with ".;" which means the current directory. See my classpath, below]
    How Classes are Found:
    http://java.sun.com/j2se/1.4/docs/tooldocs/findingclasses.html
    Examples:
    This is my path
    PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\BATCH;C:\J2SDK1.4.1\BIN;C:\PROGRA~1\UTILIT~1;C:\PROGRA~1\WIN98RK
    This is my classpath
    CLASSPATH=.;C:\mjava;C:\mnrx;C:\NetRexx\lib\NetRexxC.jar;C:\j2sdk1.4.1\lib\tools.jar;C:\NetRexx\NrxRedBk

  • Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp

    I have set the path, classpath and also compiled the HelloWorldApp.java file and my main is public static void main.
    public class HelloWorldApp
    public static void main(String[] args)
    // Display "Hello World!"
    System.out.println("Hello World!");
    I still get this error
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp

    For better understanding:
    I have set the classpath in the autoexec.bat following:
    set CLASSPATH="C:\TEST;.;";
    and I have a userdefined class in c:\jdk1.3.1_01\jre\lib\ext\myclass.jar
    compiling works, but when I run the program in c:\TEST\Hello.java I get the java.lang.NoClassDefFoundError Message.
    My source code looks like this:
    import myclass.*;
    public class Hello extends MyClass{
         public static void main(String[] args)     {
              System.out.println("Hello");

  • Exception in thread "main" java.lang.NoClassDetFoundError:

    When I compile my programs in textpad they compile fine. However when I try to run them I get the error message
    Exception in thread "main" java.lang.NoClassDetFoundError: ch4ex25
    I have no idea what to do. Please help.

    Follow this tutorial very carefully:
    Lesson: Your First Cup of Java
    It explains step by step what to do and what that error message means.

  • Exception in thread "main" java.lang.NoClassDefFoundError

    Am using java 1.3.1 on Red Hat Linux 7.1
    i get this error
    Exception in thread "main" java.lang.NoClassDefFoundError
    while running a simple program HelloWorld.java
    help

    When you use the "java" command, the only required argument is the name of the class that you want to execute. This argument must be a class name, not a file name, and class names are case sensitive. For example, "java HelloWorld.java" won't work because the class name isn't HelloWorld.java, it's HelloWorld. Similarly, "java helloworld" won't work because a class defined as "public class HelloWorld {" is not named helloworld due to case sensitivity. Finally, the .class file must be in a directory that is in the Classpath - that's where java.exe searches to find the file that contains the class.

  • HELP Needed with this error:   Exception in thread "main" java.lang.NoClass

    Folks,
    I am having a problem connecting to my MSDE SQL 2000 DB on a WindowsXP pro. environment. I am learning Java and writing a small test prgm to connect the the database. The code compiles ok, but when I try to execute it i keep getting this error:
    "Exception in thread "main" java.lang.NoClassDefFoundError: Test1"
    I am using the Microsoft jdbc driver and my CLASSPATH is setup correctly, I've also noticed that several people have complained about this error, but have not seen any solutions....can someone help ?
    Here is the one of the test programs that I am using:
    import java.sql.*;
    * Microsoft SQL Server JDBC test program
    public class Test1 {
    public Test1() throws Exception {
    // Get connection
    DriverManager.registerDriver(new
    com.microsoft.jdbc.sqlserver.SQLServerDriver());
    Connection connection = DriverManager.getConnection(
    "jdbc:microsoft:sqlserver://LAPTOP01:1433","sa","sqladmin");
    if (connection != null) {
    System.out.println();
    System.out.println("Successfully connected");
    System.out.println();
    // Meta data
    DatabaseMetaData meta = connection.getMetaData();
    System.out.println("\nDriver Information");
    System.out.println("Driver Name: "
    + meta.getDriverName());
    System.out.println("Driver Version: "
    + meta.getDriverVersion());
    System.out.println("\nDatabase Information ");
    System.out.println("Database Name: "
    + meta.getDatabaseProductName());
    System.out.println("Database Version: "+
    meta.getDatabaseProductVersion());
    } // Test
    public static void main (String args[]) throws Exception {
    Test1 test = new Test1();

    I want to say that there was nothing wrong
    with my classpath config., I am still not sure why
    that didn't work, there is what I did to resolved
    this issue.You can say that all you like but if you are getting NoClassDefFound errors, that's because the class associated with the error is not in your classpath.
    (For future reference: you will find it easier to solve problems if you assume that the problem is your fault, instead of trying to blame something else. It almost always is your fault -- at least that's been my experience.)
    1. I had to set my DB connection protocol to TCP/IP
    (this was not the default), this was done by running
    the
    file "svrnetcn.exe" and then in the SQL Server Network
    Utility window, enable TCP/IP and set the port to
    1433.Irrelevant to the classpath problem.
    2. I then copied all three of the Microsoft JDBC
    driver files to the ..\jre\lib\ext dir of my jdk
    installed dir.The classpath always includes all jar files in this directory. That's why doing that fixed your problem. My bet is that you didn't have the jar file containing the driver in your classpath before, you just had the directory containing that jar file.
    3. Updated my OS path to located these files
    and....BINGO! (that simple)Unnecessary for solving classpath problems.
    4. Took a crash course on JDBC & basic Java and now I
    have created my database, all tables, scripts,
    stored procedures and can read/write and do all kinds
    of neat stuff.All's well that ends well. After a few months you'll wonder what all the fuss was about.

  • FB 4.7 AIR 3.6 Flex 4.9 iOS packing - Exception in thread "main" java.lang.OutOfMemoryError'

    I've got an error similar to Isaac_Sunkes' 'FB 4.7 iOS packaging - Exception in thread "main" java.lang.OutOfMemoryError',
    but the causes are not related to what he discovered, corrupt image or other files, I'd exclude bad archive contents in my project.
    I'm using Flash Builder 4.7 with Adobe AIR 3.6 set into an Apache Flex 4.9.1 SDK;
    HW system is:
    iMac,    2,7 GHz Intel Core i5,    8 GB 1600 MHz DDR3,    NVIDIA GeForce GT 640M 512 MB,    OS X 10.8.2 (12C3103)
    The Flash project consists in an application with a main SWF file which loads, via ActionScript methods, other SWF in cascade.
    I've formerly compiled and run the application on an iPad 1, IOS 5.0.1 (9A405), but got on the device the error alert:
    "Uncompiled ActionScript
    Your application is attempitng to run
    uncompiled ActionScript, probably
    due to the use of an embedded
    SWF. This is unsupported on iOS.
    See the Adobe Developer
    Connection website for more info."
    Then I changed the FB compiler switches, now are set to:
    -locale en_US
    -swf-version=19
    Please note that without the switch    -swf-version=19     the application is compiled correctly and the IPA is sent to the device
    and I can debug it, but iOS traps secondary SWF files and blocke the app usage, as previously told.
    they work on deploy of small applications,
    but, when I try to build a big IPA file either for an ad-hoc distribution, either for an debug on device, after some minutes long waiting, I get a Java stuck, with this trace:
    Error occurred while packaging the application:
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.util.HashMap.addEntry(HashMap.java:753)
        at java.util.HashMap.put(HashMap.java:385)
        at java.util.HashSet.add(HashSet.java:200)
        at adobe.abc.Algorithms.addUses(Algorithms.java:165)
        at adobe.abc.Algorithms.findUses(Algorithms.java:187)
        at adobe.abc.GlobalOptimizer.sccp(GlobalOptimizer.java:4731)
        at adobe.abc.GlobalOptimizer.optimize(GlobalOptimizer.java:3615)
        at adobe.abc.GlobalOptimizer.optimize(GlobalOptimizer.java:2309)
        at adobe.abc.LLVMEmitter.optimizeABCs(LLVMEmitter.java:532)
        at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:341)
        at com.adobe.air.ipa.AOTCompiler.convertAbcToLlvmBitcodeImpl(AOTCompiler .java:599)
        at com.adobe.air.ipa.BitcodeGenerator.main(BitcodeGenerator.java:104)
    I've tried to change the Java settings on FB's eclipse.ini in MacOS folder,
    -vmargs
    -Xms(various settings up to)1024m
    -Xmx(various settings up to)1024m
    -XX:MaxPermSize=(various settings up to)512m
    -XX:PermSize=(various settings up to)256m
    but results are the same.
    Now settings are back as recommended:
    -vmargs
    -Xms256m
    -Xmx512m
    -XX:MaxPermSize=256m
    -XX:PermSize=64m
    I've changed the Flex build.properties
    jvm.args = ${local.d32} -Xms64m -Xmx1024m -ea -Dapple.awt.UIElement=true
    with no results; now I'n get back to the standard:
    jvm.args = ${local.d32} -Xms64m -Xmx384m -ea -Dapple.awt.UIElement=true
    and now I truely have no more ideas;
    could anyone give an help?
    many thanks in advance.

    I solved this. It turns out the app icons were corrupt. After removing them and replacing them with new files this error went away.

  • Problem about "Exception in thread "main" java.lang.NullPointerException"

    This is t error message once i run the file
    Exception in thread "main" java.lang.NullPointerException
    at sendInterface.<init>(sendInterface.java:64)
    at sendInterface.main(sendInterface.java:133)
    * @(#)sendInterface.java
    * @author
    * @version 1.00 2008/7/18
    import java.awt.BorderLayout;
    import java.awt.Image;
    import java.awt.GridLayout;
    import java.awt.Panel;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.DefaultListModel;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JRadioButton;
    import javax.swing.JScrollPane;
    import javax.swing.ListModel;
    import javax.swing.UIManager;
    import javax.swing.SwingConstants;
    import java.io.*;
    import java.sql.*;
    import java.net.*;
    public class sendInterface  /*implements ActionListener*/{
         JFrame frame = new JFrame();
         private Panel topPanel;
         private Panel sendMessagePanel;
         private Panel sendFilePanel;
         private JLabel senderID;
         private JLabel receiverID;
         private JLabel senderDisplay;
         private DefaultListModel receiverListModel = new DefaultListModel();
         private JList receiverID_lst = new JList(receiverListModel);
         private JRadioButton sendType;
         String userName;
         String[] userList = null ;
         int i=0;
         Connection con;     
        public sendInterface() {
             String ListName;
                 try
                     JFrame.setDefaultLookAndFeelDecorated( true );
              catch (Exception e)
               System.err.println( "Look and feel not set." );
           frame.setTitle( "Send Interface" );
             topPanel.setLayout( new GridLayout( 2 , 1 ) );                          //line 64*************************
             senderID = new JLabel( "Sender:", SwingConstants.LEFT );
             senderDisplay = new JLabel( "'+...+'", SwingConstants.LEFT );
             receiverID = new JLabel( "Receiver:", SwingConstants.LEFT);
    //         receiverID_lst = new JList( ListName );
              frame.add(senderID);
             frame.add(senderDisplay);
             frame.add(receiverID);
    //         frame.add(receiverListModel);
             frame.add(new JScrollPane(receiverID_lst), BorderLayout.CENTER);
             frame.setLocation(200, 200);
             frame.setSize(250, 90);
             frame.setVisible(true);
        public void setListName(String user)
             try{
                  userName = user;
                  Class.forName("com.mysql.jdbc.Driver");
                   String url = "jdbc:mysql://localhost:3306/thesis";
                   con = DriverManager.getConnection(url, "root", "");
                   Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
                   ResultSet rs = stmt.executeQuery("select * from user where User_ID!= '" + userName + "'");
                   System.out.println("Display all results:");
                   while(rs.next()){
                      String user_id = rs.getString("User_ID");
                      System.out.println("\tuser_id= " + user_id );
         //             receiverListModel.addElement(user_id);
                        userList=user_id;
                        i++;
              }//end while loop
              receiverListModel.addElement(userList);
         catch(Exception ex)
    ex.printStackTrace();
         finally
    if (con != null)
    try
    con.close ();
    System.out.println ("Database connection terminated");
    catch (Exception e) { /* ignore close errors */ }
    public String getUserName()
         return userName;
    public String[] getUserList()
         return userList;
    public static void main(String[] args) {
    new sendInterface(); //line 133******************************************
    thank ur reply:D
    Edited by: ocibala on Aug 3, 2008 9:54 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    And where do you instantiate topPanel before you invoke setLayout?
    db

Maybe you are looking for

  • In Automatic Payment Prog - MT103 Problem

    Dear Friends, I have a problem for Automatic Payment Programme, I am Using MT103 format when i run Automatic Payment Programme it is Ok everything Fine it posted correclty, when i want to create DME file through this T.Code - FBPM - it is also workin

  • Can't open quicktime movie that I exported from Motion 5 and can't import to FCP

    Can't open quicktime movie that I exported from Motion 5 and can't import to FCP 7. I exported (with current settings) from Motion 5 now i can't view my movie with QT Player an FCP won't recognize it. That's the message I get ? I'm running Mac OSX bu

  • HCP tcode PA40 Upload program failing to move to next record.

    Dear All I have written and upload program for HCM tcode PA40 and the program is fine but only inserting one record and is failing to pick the next records in a loop. I dont know whats the problem i know the process have many screens, please help me,

  • Looking  for book recommendations and version comparisons

    My company is switching to WLS 10.0 (from a non-WebLogic server), and I would like to find a book on the subject. Ideally, but not necessarily, it would cover J2EE as well. I have been looking around a bit, and most of the books cover previous versio

  • Photoshop 7 locks up when selecting the color picker.

    My wonderful Photoshop 7 has worked perfectly for years, but now, when selecting the colour picker, the whole site locks up, requiring ending the task and losing the work in hand.