Program Compiles, but Exception in thread "main" error is thrown

Hello everybody,
I am getting the following error when I try to run my program. It compiles fine, but a Exception in thread "main" error is given when I try to run the program. This is the full error:
Exception in thread "main" java.lang.Error: Do not use KonnectHelpdeskFrame.add(
) use KonnectHelpdeskFrame.getContentPane().add() instead
        at javax.swing.JFrame.createRootPaneException(JFrame.java:446)
        at javax.swing.JFrame.addImpl(JFrame.java:472)
        at java.awt.Container.add(Container.java:298)
        at KonnectHelpdesk.main(KonnectHelpdesk.java:15)
Press any key to continue . . .The code that I beleive contributes to the error is below. I'm not sure what is causing the problem, so any help will be greatly appreciated. Thanks.
class VoiceMailEntryDialog extends JDialog
     public VoiceMailEntryDialog(JFrame owner)
          super(owner, "New Voicemail Entry", true);
          Container contentPane = getContentPane();
          GridBagLayout layout = new GridBagLayout();
          contentPane.setLayout(layout);
          JLabel numberLabel = new JLabel("Phone Number: ");
          JLabel dayCalledLabel = new JLabel("Day Customer Called: ");
          JLabel timeCalledLabel = new JLabel("Time Customer Called: ");
          JLabel firstNameLabel = new JLabel("First Name: ");
          JLabel lastNameLabel = new JLabel("Last Name: ");
          JLabel messageLabel = new JLabel("Message: ");
          JTextField phoneNumber = new JTextField(20);
          JTextField firstName = new JTextField(20);
          JTextField lastName = new JTextField(30);
          JTextArea message = new JTextArea(8, 30);
          message.setLineWrap(true);
          message.setBorder(BorderFactory.createEtchedBorder());
          JComboBox dayCalled = new JComboBox(new String[]
               "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday"
          JComboBox timeCalled = new JComboBox(new String[]
               "9:30am - 9:59am", "10:00am - 10:59am", "11:00am - 11:59am", "12:00pm - 12:59pm",
               "1:00pm - 1:59pm", "2:00pm - 2:59pm", "3:00pm - 3:59pm", "4:00pm - 4:59pm",
               "5:00pm - 5:59pm", "6:00pm - 6:59pm", "7:00pm - 7:59pm", "8:00pm - 8:59pm",
               "9:00pm - 9:59pm", "10:00pm - 9:29am"
          ActionListener noMsgListener = new NoMessageChecked();
          JCheckBox noMessageCheckbox = new JCheckBox("Left no message");
          noMessageCheckbox.addActionListener(noMsgListener);
          JButton ok = new JButton("OK");
          ok.addActionListener(new ActionListener()
               public void actionPerformed(ActionEvent evt)
                    setVisible(false);
          JButton cancel = new JButton("Cancel");
          cancel.addActionListener(new ActionListener()
               public void actionPerformed(ActionEvent evt)
                    setVisible(false);
          GridBagConstraints constraints = new GridBagConstraints();
          constraints.fill = GridBagConstraints.NONE;
          constraints.anchor = GridBagConstraints.EAST;
          constraints.weightx = 0;
          constraints.weighty = 0;
          add(numberLabel, constraints, 0, 0, 1, 1);
          add(dayCalledLabel, constraints, 0, 2, 1, 1);
          add(timeCalledLabel, constraints, 0, 4, 1, 1);
          setSize(400, 700);
     public void add(Component c, GridBagConstraints constraints, int x, int y, int w, int h)
          constraints.gridx = x;
          constraints.gridy = y;
          constraints.gridwidth = w;
          constraints.gridheight = h;
          getContentPane().add(c, constraints);
     private class NoMessageChecked implements ActionListener
          public void actionPerformed(ActionEvent event)
}

atmguy,
Thanks. It turns out the the line that was causing the problem was in the error message. I guess it helps to pay attention. You are correct in what the line says and changing it made the program run, but caused some other minor problems that I'll work out later. Thanks again for you help.
jerryrika

Similar Messages

  • Exception in thread "main" error

    I have a real problem. I am trying to write a hello world program in java using native code. my java code is as follow :
    class HelloWorld {
    static {
    System.loadLibrary("Hello.so");
    private native void print();
    public static void main(String[] args) {
    new HelloWorld().print();
    System.out.println("Good bye Hello World!!");
    my native c code is as follow :
    #include <jni.h>
    #include <stdio.h>
    #include "HelloWorld.h"
    JNIEXPORT void JNICALL
    print(JNIEnv *env,jobject obj) {
    printf("Hello cruel world. Hope you can live through the Human Phase!.\n");
    return ;
    I use javac HelloWorld.java to get my HelloWorld.class file.
    I use javah HelloWorld to het my HelloWorld.h file
    i set my LD_LOBRARY_PATH to where my native code is.
    i compile the c code using "
    gcc -c -I /usr/java/j2sdk1.4.0/include -I /usr/java/j2sdk1.4.0/include/linux HelloWorld.c -o Hello.so
    everything is good up to this point. But when i call java HelloWorld, i get the following error : "
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no Hello.so in java.library.path     at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1370)
         at java.lang.Runtime.loadLibrary0(Runtime.java:773)
         at java.lang.System.loadLibrary(System.java:835)
         at HelloWorld.<clinit>(HelloWorld.java:3)
    Can any one help. I am using RedHat 7.2, kernel 2.4.10-17.
    Thank you
    Shafi Jourabchi [email protected]

    Thank you all who have responded. The solution to my problem was with the compile options. I was not using the right option to compile the shared lib object file.
    the command i used ( and it worked ) was :
    gcc -o libHello.so -shared -Wl, -soname,libHello.so -I /usr/java/j2sdk/include -I /usr/java/j2sdk/include/linux HelloWorldImp.c -static -Lc
    Shafi jourabchi

  • Exception in thread "main" - error: Please help

    I installed the Java 1.4.0 beta on my machine. I configured the JRE and the javac and java commands are responding well. Now I have written very simple classes which are compiling without errors. But now, if I use the java command to run the classes, I am getting the following message:
    Exception in thread "main" java.lang.NoClassFoundError: ForTick/class ;
    where ForTick is the name of my class for example. Where am I going wrong? Also, where do I find documentation for error messages like this - I have toured almost the whole java website and even the documentation that I downloaded -but I couldn't find it.
    Please help me coz I am just stuck.

    Did you try
    java ForTick.class ?
    If so, please try
    java ForTickHope this helps

  • "exception in thread main" error while running "dbca"

    Hi,
    i am getting following kind of error while trying to run dbca in linux.
    "exception in thread main"
    i have the dispaly env var set. and xhost+ set too. but still dbca is not working.
    i have pasted the contents of dbca file below. can someone have a look at the file and help me find the error.
    it would be great if someone can paste their dbca file content, so i can compare and fix the error.
    #!/bin/sh -f
    # $Header: dbca.sh 12-may-2005.11:05:03 xuliu Exp $
    # dbca.sh
    # Copyright (c) 1997, 2005, Oracle. All rights reserved.
    # NAME
    # dbassist - Shell script to run Database Creation Assistant
    # DESCRIPTION
    # Runs Database Creation Assistion java application
    # Run this script with -h or -help option to get the help.
    # MODIFIED (MMDD/YY)
    # npamnani 10/23/02 - add 1.3.1. java flag
    # npamnani 10/09/02 - run with java instead jre
    # dkapoor 07/05/2000 - Created
    # Variables set by Oracle Universal Installer for dependent components.
    # Define ORACLE_HOME -> OH
    OH=/home/oracle/oracle/product/10.2.0/db_1
    PLATFORM=Linux
    ORACLE_HOME=$OH
    export ORACLE_HOME;
    # Version specific JAR files
    JRE_FILE=rt.jar
    I18_FILE=i18n.jar
    EWT_FILE=ewt3.jar
    JEWT_FILE=jewt4.jar
    EWT_COMP_FILE=ewtcompat-3_3_15.jar
    SHARE_FILE=share.jar
    HELP_FILE=help4.jar
    #ICE_BROWSER_FILE=oracle_ice5.jar
    ICE_BROWSER5_FILE=oracle_ice5.jar
    KODIAK_FILE=kodiak.jar
    SWING_FILE=swingall-1_1_1.jar
    XMLPARSER_FILE=xmlparserv2.jar
    JDBC_FILE=classes12.zip
    GDK_FILE1=orai18n.jar
    GDK_FILE2=orai18n-mapping.jar
    GDK_FILE3=orai18n-utility.jar
    GDK_FILE4=orai18n-collation.jar
    NETCFG_FILE=netcfg.jar
    OJMISC_FILE=ojmisc.jar
    PKI_FILE=oraclepki103.jar
    LDAP_FILE=ldapjclnt10.jar
    OPM_FILE=opm.jar
    SRVM_FILE=srvm.jar
    SRVMHAS_FILE=srvmhas.jar
    SRVMASM_FILE=srvmasm.jar
    ASSISTANTS_COMMON_FILE=assistantsCommon.jar
    DBCA_FILE=dbca.jar
    EMLITE_JAR=oemlt-10_1_0.jar
    INSTALLER_FILE=OraInstaller.jar
    PREREQ_JAR_FILE=OraPrereq.jar
    PREREQ_CHECKS_JAR_FILE=OraPrereqChecks.jar
    # Directory Variables
    SRVM_JLIB_DIR=/home/oracle/oracle/product/10.2.0/db_1/jlib
    JRE_DIR=/home/oracle/oracle/product/10.2.0/db_1/jdk/jre
    LIB_DIR=$OH/lib
    LIB32_DIR=$OH/lib32
    JLIB_DIR=$OH/jlib
    DBCA_JLIB_DIR=$OH/assistants/dbca/jlib
    ASSISTANTS_JLIB_DIR=$OH/assistants/jlib
    INSTALLER_JLIB_DIR=/home/oracle/oracle/product/10.2.0/db_1/oui/jlib
    # Classpath
    JRE_CLASSPATH=$JRE_DIR/lib/$JRE_FILE
    I18_CLASSPATH=$JRE_DIR/lib/$I18_FILE
    EWT_CLASSPATH=$JLIB_DIR/$EWT_FILE:$JLIB_DIR/$EWT_COMP_FILE
    SHARE_CLASSPATH=$JLIB_DIR/$SHARE_FILE
    HELP_CLASSPATH=$JLIB_DIR/$HELP_FILE:$JLIB_DIR/$JEWT_FILE
    ICE_BROWSER_CLASSPATH=$JLIB_DIR/$ICE_BROWSER5_FILE
    KODIAK_CLASSPATH=$JLIB_DIR/$KODIAK_FILE
    SWING_CLASSPATH=$JLIB_DIR/$SWING_FILE
    XMLPARSER_CLASSPATH=/home/oracle/oracle/product/10.2.0/db_1/lib/$XMLPARSER_FILE
    JDBC_CLASSPATH=$OH/jdbc/lib/$JDBC_FILE
    GDK_CLASSPATH=$JLIB_DIR/$GDK_FILE1:$JLIB_DIR/$GDK_FILE2:$JLIB_DIR/$GDK_FILE3:$JLIB_DIR/$GDK_FILE4
    NETCFG_CLASSPATH=$JLIB_DIR/$NETCFG_FILE:$JLIB_DIR/$OJMISC_FILE:$JLIB_DIR/$PKI_FILE:$JLIB_DIR/$LDAP_FILE:$JLIB_DIR/$OPM_FILE
    SRVM_CLASSPATH=$SRVM_JLIB_DIR/$SRVM_FILE:$SRVM_JLIB_DIR/$SRVMHAS_FILE:$SRVM_JLIB_DIR/$SRVMASM_FILE
    EM_CLASSPATH=$OH/classes:$JLIB_DIR/$EMLITE_JAR:$JLIB_DIR/emca.jar:$OH/sysman/jlib/emCORE.jar:$OH/oc4j/j2ee/home/oc4j.jar:$OH/oc4j/j2ee/home/db_oc4j_deploy.jar:$JLIB_DIR/emConfigInstall.jar
    ASSISTANTS_COMMON_CLASSPATH=$ASSISTANTS_JLIB_DIR/$ASSISTANTS_COMMON_FILE
    DBCA_CLASSPATH=$DBCA_JLIB_DIR/$DBCA_FILE
    INSTALLER_CLASSPATH=$INSTALLER_JLIB_DIR/$INSTALLER_FILE:$INSTALLER_JLIB_DIR/$PREREQ_JAR_FILE:$OH/inventory/prereqs/oui/$PREREQ_CHECKS_JAR_FILE:$INSTALLER_JLIB_DIR/$PREREQ_CHECKS_JAR_FILE
    # Check for silent or help
    SILENT="false"
    for i in $*
    do
    if [ $i = "-silent"  ] || [ $i = "-help"  ] || [ $i = "-h"  ]; then
    SILENT="true"
    break
    fi
    done
    # Check for DISPLAY
    if [ $SILENT = "false"  ]; then
    case $DISPLAY in
    echo "DISPLAY not set."
    echo "Set DISPLAY environment variable, then re-run."
    exit;
    esac
    fi
    # make sure others can not read/write any files created
    umask 27
    # The environment variable $TWO_TASK cannot be set during the installation
    unset TWO_TASK
    # The environment variable $JAVA_HOME cannot be set during the installation
    unset JAVA_HOME
    # Basic error checking
    case $OH in
    "") echo "*** ORACLE_HOME Not Set!"
    echo " Set and export ORACLE_HOME, then re-run"
    echo " ORACLE_HOME points to the main directory that"
    echo " contains all Oracle products."
    exit 1;;
    esac
    # Set the LD_LIBRARY_PATH to set the path for shared objects
    # Do not set it on AIX
    if [ $PLATFORM != IBM_AIX ]; then
    LD_LIBRARY_PATH=$LIB32_DIR:$OH/network/lib32:$LIB_DIR:$OH/network/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH;
    fi
    # Set SHLIB_PATH for HP to use 32bit native libraries
    SHLIB_PATH=$LIB32_DIR:$ORACLE_HOME/network/lib32:$SHLIB_PATH
    export SHLIB_PATH;
    # Set LIBPATH for AIX to use 32bit native libraries
    LIBPATH=$LIB32_DIR:$ORACLE_HOME/network/lib32:$LIBPATH
    export LIBPATH;
    # Set Classpath for Database Creation Assistant
    CLASSPATH=$JRE_CLASSPATH:$I18_CLASSPATH:$DBCA_CLASSPATH:$ASSISTANTS_COMMON_CLASSPATH:$EWT_CLASSPATH:$SHARE_CLASSPATH:$HELP_CLASSPATH:$ICE_BROWSER_CLASSPATH:$KODIAK_CLASSPATH:$SWING_CLASSPATH:$XMLPARSER_CLASSPATH:$GDK_CLASSPATH:$NETCFG_CLASSPATH:$JDBC_CLASSPATH:$SRVM_CLASSPATH:$EM_CLASSPATH:$INSTALLER_CLASSPATH
    ARGUMENTS=""
    NUMBER_OF_ARGUMENTS=$#
    if [ $NUMBER_OF_ARGUMENTS -gt 0 ]; then
    ARGUMENTS=$*
    fi
    # Run DBCA
    $JRE_DIR/bin/java -Dsun.java2d.font.DisableAlgorithmicStyles=true -DORACLE_HOME=$OH -DDISPLAY=$DISPLAY -DJDBC_PROTOCOL=thin -mx128m -classpath $CLASSPATH oracle.sysman.assistants.dbca.Dbca $ARGUMENTS
    Thanks,
    Philip.

    I got this error also,.
    After restart the computer, it runs ok.

  • Air iOS compile issue Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 14

    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 14
              at adobe.abc.GlobalOptimizer$InputAbc.readCode(GlobalOptimizer.java:1510)
              at adobe.abc.GlobalOptimizer$InputAbc.readBody(GlobalOptimizer.java:682)
              at adobe.abc.GlobalOptimizer$InputAbc.readBodies(GlobalOptimizer.java:403)
              at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:326)
              at com.adobe.air.ipa.AOTCompiler.convertAbcToLlvmBitcodeImpl(AOTCompiler.java:472)
              at com.adobe.air.ipa.BitcodeGenerator.main(BitcodeGenerator.java:82)
    Compilation failed while executing : ADT
    only happens on compiling for iOS, not for Android
    Air 3.1, and flash builder 4.6

    how about this
        public static void main(String[] args)  {
            if(args.length!=2) {
                 System.out.println("Write TWO arguments");
                 return;
            ChatClient client = new ChatClient(args[0], args[1]);
            client.listen();
        }that should make it check that the array length is 2, and inform the user to write 2 arguments if they get it wrong

  • Doubt in AXIS-Exception in thread "main" . how can i run this program

    hi
    I am new to axis., I done few webservice program using Jwsdp
    i can't resolve the reason for this exception.
    I have set all the classpath and other path variable that is necessary for axis .,
    I got this example from http://javaboutique.internet.com/tutorials/Axis/index.html
    Can any one help to solve this problem.,
    **************Code***************
    import java.util.*;
    public class NHLService {
      HashMap standings = new HashMap();
      public NHLService() {
        // NHL - part of the standings as per 04/07/2002
        standings.put("atlantic/philadelphia", "1");
        standings.put("atlantic/ny islanders", "2");
        standings.put("atlantic/new jersey", "3");
        standings.put("central/detroit", "1");
        standings.put("central/chicago", "2");
        standings.put("central/st.louis", "3");
      public String getCurrentPosition(String division, String team) {
        String p = (String)standings.get(division + '/' + team);
        return (p == null) ? "Team not found" : p;
    package hansen.playground;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import javax.xml.rpc.namespace.QName;
    import java.net.*;
    public class NHLServiceClient {
       public static void main(String [] args) throws Exception {
           Service service = new Service();
           Call call = (Call)service.createCall();
           String endpoint = "http://localhost:8081/axis/NHLService.jws";
           call.setTargetEndpointAddress(new URL(endpoint));
           call.setOperationName(new QName("getCurrentPosition"));
           String division = args[0];
           String team = args[1];
           String position =
             (String)call.invoke(new Object [] {new String(division), new String(team)});
           System.out.println("Got result : " + position);
    }************ classpath***************
    :/home/sujithkr/webservices/xml-axis/java:
    /home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/axis.jar
    /home/sujithkr/webservices/xml-axis/lib/activation.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/clutil.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/commons-logging.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/jaxrpc.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/log4j-core.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/tt-bytecode.jar
    ********************Error Report*******************************
    java hansen.playground.NHLServiceClient atlantic philadelphia
    Exception in thread "main" Error while compiling: /usr/local/tomcat/webapps/axis//NHLService.java
    at org.apache.axis.message.SOAPFaultBuilder.endElement(Unknown Source)
    at org.apache.axis.encoding.DeserializationContextImpl.endElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
    at org.apache.axis.encoding.DeserializationContextImpl.parse(Unknown Source)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at hansen.playground.NHLServiceClient.main(NHLServiceClient.java:21)
    suse-1:/home/sujithkr/webservices # clear
    suse-1:/home/sujithkr/webservices # java hansen.playground.NHLServiceClient atlantic philadelphia
    Exception in thread "main" Error while compiling: /usr/local/tomcat/webapps/axis//NHLService.java
    at org.apache.axis.message.SOAPFaultBuilder.endElement(Unknown Source)
    at org.apache.axis.encoding.DeserializationContextImpl.endElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
    at org.apache.axis.encoding.DeserializationContextImpl.parse(Unknown Source)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at hansen.playground.NHLServiceClient.main(NHLServiceClient.java:21)
    thank you for helping me in your hectic schedule....

    Please post your code using code tags.
    When I try to compile or build i cant.What is your question? Exactly what error message do you get?

  • "Exception in thread "main" java.lang. No Class Def Found Error: Env"

    iam getting this erro message when i want to run the
    java program "Hello World"
    "Exception in thread "main" java.lang. No Class Def Found Error: Env"
    I have set environment variable for classpath and path for the jdk1.3.
    It is getting compiled without any error. When i try to run it it spits this error message:
    Help me......

    The problem could be from several reasons.
    If you're trying to run HelloWorld.java, you're class should defined as
    public class HelloWorld {
    public static void main(String[] args) {
    System.out.println("Hello World");
    This program must be in a file called HelloWorld.java
    to compile-- javac HelloWorld.java
    fo run--- java HelloWorld
    1. The class has to be public
    2. you must have a main method.
    3. The file must be named the name of your class(HelloWorld) with a .java extension.
    4. After you compile make sure there is a gile called HelloWorld.class in the directory you're working in
    Steve

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

    Hiya all,
    i`ve got a problem with my compiler , it wont execute a for lus.
    so can anybody help me to solve my problem..
    this is the error that my compiler gives:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
         Syntax error, 'for each' statements are only available if source level is 5.0
         at ForEachInzend2.<init>(ForEachInzend2.java:8)
         at ForEachInzend2.main(ForEachInzend2.java:16)
    public class ForEachInzend2 {
         public ForEachInzend2(){
              int[] celblock = new int[100];
              int crimineel = 100;
              for (int cel : celblock){ //this is red underlined.
                   cel = crimineel;
                   crimineel++;
                   System.out.println("Criminelen in celblock " + cel);
         public static void main(String[] args){
              ForEachInzend2 foreachinzend2 = new ForEachInzend2();
    }

    John_Musbach wrote:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem: Unresolved compilation problem is an error that you'll only ever see if you're using an IDE. If you used the javac compiler, then you would have seen that the code doesn't even compile.
    The reason (as others have pointed out) is, that some paths through your method don't return a value.
    I'll re-write your code in the code-style that I usually use, because then it might be easier for you to see the problem:
    public boolean find(MusbachJ_Person person,BstNode node)
         if(node.intData.compareTo(person)==0) {
              return true;
         if( node.leftNode != null ) {
              find(person,node.leftNode );
         if( node.rightNode != null ) {
              find( person, node.rightNode);
         else {
              return false;
    }There are two prolbems. I'll spell out the first and let the other one for you to find:
    1.) you don't do anything with the return-values of the find-methods you are calling. What do you want to do with them?
    2.) What do you return if the current node is not the one that you want and you've got a right node?

  • Exception in thread "main" Context Value Management Failed.

    Hi
    I am facing one issue when i regenerate autoconfig.
    We are running Multi Node installation of Oracle EBS on SUN O.S, and
    when I regenerate Autoconfig, I am getting
    Using AutoConfig to configure the Applications environment
    Loading APPL_TOP environment from /u11/oracle/k24eb1appl
    Verifying Context file ...
    found context version : 115.121
    minimum required version : 115.121
    available update version : 115.178
    An update for the Context File is available.
    java.lang.NullPointerException
    at oracle.apps.ad.context.CtxValueMgt.main(Compiled Code)
    Exception in thread "main" Context Value Management Failed.
    Exiting with status 1
    Any Solutions pls
    Reg
    Sundar

    Cross posted in java-forums.
    OP, please do not cross-post without notification such as links to the other cross-posts. Nobody likes duplicating work that's already been done.

  • Exception in thread "main" during  WL6.0SP1 update on AIX4.3.3

    We are getting an Exception in thread "main" when trying to update
    wlserver6.0 on AIX 4.3.3 with SP1 file.
    We have tried with IBM or BEA JDK - same problem.
    Can someone help please? Thank you in advance,
    Jerome
    PS:
    java -cp wls60sp1_upgrade_generic.zip install -i console.....
    Choose BEA Home Directory
    1- Create a New BEA Home
    2- Use Existing BEA Home
    Enter a number: 2
    1- /dcm/bea
    Existing BEA Home: 1
    Installing...
    [==================|==================|==================|==================
    [Exception in thread "main"
    JAVA:
      Java130.adt.debug          1.3.0.4  COMMITTED  Java Application
    Development
      Java130.adt.includes       1.3.0.2  COMMITTED  Java Application
    Development
      Java130.ext.commapi        1.3.0.0  COMMITTED  Java Comm API Extension
      Java130.ext.jaas           1.3.0.3  COMMITTED  JAAS (Java Authentication &
      Java130.ext.plugin         1.3.0.4  COMMITTED  Java Plugin for Netscape
      Java130.rte.bin            1.3.0.4  COMMITTED  Java Runtime Environment
      Java130.rte.lib            1.3.0.4  COMMITTED  Java Runtime Environment
      Java130.samples.demos      1.3.0.1  COMMITTED  Java Sample Demos
    MP KERNEL:
    bos.mp                    4.3.3.26  COMMITTED  Base Operating System
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Hi Luis
    This can be a problem with the CLASSPATH. Have you checked the CLASSPATH. Do
    you have your working directory in the classpath?
    Anant
    <Luis Martins> wrote in message news:[email protected]..
    Has anyone resolved this? I have the exact same problem. No one on the web
    seems to know the solution though a efw people have this problem. I'm
    running Redhat 9 and installing Weblogic 6.1 in the same manner as Jerome.
    I get the exact same "Exception in thread "main"" error...I installed JDK
    1.3.1 and included the JDK_HOME/bin as the first entry in my $PATH
    variable.
    Can anyone please please help...this has been doing my head in. Thanks in
    advance...:)

  • Error after compile Exception in thread "main" java.lang.NoClassDefFoundErr

    Hi I am very new to Java programming, right now I am using a mac os 10.49
    I can create java documents using bbedit and then they compile when i type
    javac.
    But when i type java *.java I get the following error
    Exception in thread "main" java.lang.NoClassDefFoundError
    If I type java "filename"
    without the .java at the end of the file the terminal has no response
    I understand i am supposed to some how set the classpath but i do not know how to do this
    Also I can create and compile and then run my java in the eclipse program that i have installed, but not from terminal and im not sure why.
    Thanks for the help.

    I understand i am supposed to some how set the classpath but i do not know how
    to do thisThere is no need to set a system variable CLASSPATH, it is inflexible to do so, and it can lead to unpredictable behaviour.
    You should be able to compile and run programs from the command line, specifying the classpath as part of the commands you use.
    (1) For instance, you can create a file HelloWorld.java with the following contents:public class HelloWorld {
        public static void main(String args[]) {
            System.out.println("Hello world");
    }(2) From the command line (console) navigate to the folder (directory) containing this file and compile it with the commandjavac -cp . HelloWorld.javaThe "-cp ." part is what specifies the classpath. Note that it is a file that is being compiled so we specify the actual file name including the extension. At this point you should be able to check that the HelloWorld.class file has been created.
    (3) From the same folder (directory) you run the program withjava -cp . HelloWorldThe classpath is being specified in the same way as before. It is a class that is being invoked, so we don't specify a filename. (much less use wildcards like *).
    Documentation for the java and javac tools (and others) are linked to from this page: http://java.sun.com/javase/6/docs/index.html

  • Java Compile Error  Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 14  for iOS

    When compiling one of my projects, I am getting this error suddenly:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 14
              at adobe.abc.GlobalOptimizer$InputAbc.readCode(GlobalOptimizer.java:1510)
              at adobe.abc.GlobalOptimizer$InputAbc.readBody(GlobalOptimizer.java:682)
              at adobe.abc.GlobalOptimizer$InputAbc.readBodies(GlobalOptimizer.java:403)
              at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:326)
              at com.adobe.air.ipa.AOTCompiler.convertAbcToLlvmBitcodeImpl(AOTCompiler.java:472)
              at com.adobe.air.ipa.BitcodeGenerator.main(BitcodeGenerator.java:82)
    Compilation failed while executing : ADT
    but only when targeting iOS. fo Android only, it works fine. Anyone have any ideas? I also logged it as a bug.

    I get the I/O exception while reading: D:\Java\HelloApplet (The system cannot find the file specified). I have previously compiled HelloApplet.java into HelloApplet.class using javac.exe
    the two include statements in the sample HelloApplet I'm using are
    import java.applet.*;
    import java.awt.*;
    I also have a ComponentEventTest.java file which I've made into a class with these two
    include statements:
    import java.awt.*;
    import java.awt.event.*;
    I can however compile .java files which have no include statements.
    I take it that my classpath is not set correctly. Like I said earlier, I'm using winxp
    and trying to set the classpath variable under system. I have tried under user too. The path names I've tried setting are C:\Program Files\Java\jdk1.5.0_02\, C:\Program Files\Java\jdk1.5.0_02\lib, C:\Program Files\Java\jdk1.5.0_02\include, and C:\Program Files\Java\jdk1.5.0_02\;C:\Program Files\Java\jdk1.5.0_02\lib;C:\Program Files\Java\jdk1.5.0_02\include.
    How can I correct this? If it's possible, I would like to set a variable in windows
    versus having to type extra commands at the command prompt everytime I try
    to run a java class with java.exe. Any help would be much appreciated

  • Exception in thread "main" java.lang.Error: Unresolved compilation problem

    The following code:
         public boolean find(MusbachJ_Person person,BstNode node)
              //p.l(person);p.l(node.intData);
              if(node.intData.compareTo(person)==0)
                   return true;
              if( node.leftNode != null ) find(person,node.leftNode );
              if( node.rightNode != null ) find( person, node.rightNode);
              else
                   return false;
         }returns the following compilation error:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
         This method must return a result of type boolean
         at MusbachJ_TreeNode.find(MusbachJ_TreeNode.java:32)
         at MusbachJ_PeopleTree.main(MusbachJ_PeopleTree.java:91)
    But I don't understand, the else statement is right there, what more does it want? Thanks! :)

    John_Musbach wrote:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem: Unresolved compilation problem is an error that you'll only ever see if you're using an IDE. If you used the javac compiler, then you would have seen that the code doesn't even compile.
    The reason (as others have pointed out) is, that some paths through your method don't return a value.
    I'll re-write your code in the code-style that I usually use, because then it might be easier for you to see the problem:
    public boolean find(MusbachJ_Person person,BstNode node)
         if(node.intData.compareTo(person)==0) {
              return true;
         if( node.leftNode != null ) {
              find(person,node.leftNode );
         if( node.rightNode != null ) {
              find( person, node.rightNode);
         else {
              return false;
    }There are two prolbems. I'll spell out the first and let the other one for you to find:
    1.) you don't do anything with the return-values of the find-methods you are calling. What do you want to do with them?
    2.) What do you return if the current node is not the one that you want and you've got a right node?

  • Error of compilation for IOS: Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded

    Error of compilation for an IOS project:
    Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
    at adobe.abc.Algorithms$SetMap.get(Algorithms.java:226)
    at adobe.abc.Algorithms$ExprWorkQueue.add(Algorithms.java:491)
    at adobe.abc.Algorithms$ExprWorkQueue.addAll(Algorithms.java:524)
    at adobe.abc.GlobalOptimizer.sccp_analyze(GlobalOptimizer.java:6007)
    at adobe.abc.GlobalOptimizer.sccp(GlobalOptimizer.java:4733)
    at adobe.abc.GlobalOptimizer.optimize(GlobalOptimizer.java:3615)
    at adobe.abc.GlobalOptimizer.optimize(GlobalOptimizer.java:2309)
    at adobe.abc.LLVMEmitter.optimizeABCs(LLVMEmitter.java:534)
    at adobe.abc.LLVMEmitter.generateBitcode(LLVMEmitter.java:343)
    at com.adobe.air.ipa.GOAOTCompiler.convertAbcToLlvmBitcodeImpl(GOAOTCompiler.java:243)
    at com.adobe.air.ipa.BitcodeGenerator.main(BitcodeGenerator.java:85)
    Compilation failed while executing : ADT
    We allocate 4GB of memory for the compilator and the results is the same. The build is very long (~5 min)

    See if this helps
    OutOfMemoryError: GC overhead limit exceeded when heap is just fine
    regards
    Pravin

  • 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.

Maybe you are looking for

  • IMac display won't sleep with hot corner

    I saw that this question was asked before but no answer was given. I got my iMac OS X Yosemite 10.10 brand new yesterday. I set up hot corners so that the display will go to sleep when I swipe it. However, no matter how carefully I swipe, it always c

  • How do I make Photoshop the default Edit App for .jpg in Windows 7?

    How do I make Photoshop the default Edit App for .jpg in Windows 7?    I want to be able to right click on a .jpg file, select the EDIT option in the Context Menu, then have Photoshop edit the file instead of Paint. In Windows XP it was very easy to

  • Photo bug after upgrade to iOS 5.01

    Today I upgraded my iPad 1 to iOS5.01. After the succesful upgrade I created some new folders with photos on my PC, and synced my iPad. When I open the photo app on iPad, and then open the new albums I created today, and then close the albums again,

  • Best MacBook Pro for my needs

    I know there's tons of talk on this topic but I want to see if I can narrow it down to my specific needs. I'm debating between the high end 13" rMBP (standard config) vs high end 15" (i7' 16gb, 512gb, 750m) My primary use will be web design and heavy

  • My creative cloud desktop app

    will not upgrade or open- need help reinstalling- i am a paid subscriber and can't find link to reinstall