Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Please help with exceptions

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help with exceptions

    Exception in thread "main" CustomTesterApp$TestException
    at CustomTesterApp.getTestException(CustomTesterApp.j ava:32)
    at CustomTesterApp.Method3(CustomTesterApp.java:28)
    at CustomTesterApp.Method2(CustomTesterApp.java:22)
    at CustomTesterApp.Method1(CustomTesterApp.java:17)
    at CustomTesterApp.main(CustomTesterApp.java:12)
    Java Result: 1

    I am getting no errors but when I go to run the program I get this and my build is successful please help


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Please help with exceptions

    Exception in thread "main" CustomTesterApp$TestException
    at CustomTesterApp.getTestException(CustomTesterApp.j ava:32)
    What does the code at line 32 do?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Please help with exceptions

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Can you post your code? If so, please postit correctly per the above link.

  4. #4
    Junior Member
    Join Date
    May 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help with exceptions

    Thank you I am not longer getting those problems now I get no errors but the program will not catch, I am getting no results at all. Not sure if I have done the excerize correctly or not. Below is what Netbeans gives me when I run it:

    ant -f C:\\Users\\marieanne\\Desktop\\netbeans\\ex_starts \\ch14_ex3_CustomerTester -Dnb.internal.action.name=run run
    init:
    Deleting: C:\Users\marieanne\Desktop\netbeans\ex_starts\ch14 _ex3_CustomerTester\build\built-jar.properties
    deps-jar:
    Updating property file: C:\Users\marieanne\Desktop\netbeans\ex_starts\ch14 _ex3_CustomerTester\build\built-jar.properties
    Copying 15 files to C:\Users\marieanne\Desktop\netbeans\ex_starts\ch14 _ex3_CustomerTester\build\classes
    Copied 12 empty directories to 4 empty directories under C:\Users\marieanne\Desktop\netbeans\ex_starts\ch14 _ex3_CustomerTester\build\classes
    compile:
    run:
    BUILD SUCCESSFUL (total time: 0 seconds)

    --- Update ---

    Thank you I am not longer getting those problems now I get no errors but the program will not catch, I am getting no results at all. Not sure if I have done the excerize correctly or not. Below is what Netbeans gives me when I run it:

    ant -f C:\\Users\\marieanne\\Desktop\\netbeans\\ex_starts \\ch14_ex3_CustomerTester -Dnb.internal.action.name=run run
    init:
    Deleting: C:\Users\marieanne\Desktop\netbeans\ex_starts\ch14 _ex3_CustomerTester\build\built-jar.properties
    deps-jar:
    Updating property file: C:\Users\marieanne\Desktop\netbeans\ex_starts\ch14 _ex3_CustomerTester\build\built-jar.properties
    Copying 15 files to C:\Users\marieanne\Desktop\netbeans\ex_starts\ch14 _ex3_CustomerTester\build\classes
    Copied 12 empty directories to 4 empty directories under C:\Users\marieanne\Desktop\netbeans\ex_starts\ch14 _ex3_CustomerTester\build\classes
    compile:
    run:
    BUILD SUCCESSFUL (total time: 0 seconds)

    --- Update ---

    /*
    In creating custom exception there are no errors
    have done clean and build project and build was successful hope this correct
    Author: Marieanne Begg
    Date: 5/26/14
    Project: To make a custom Exception (done), to throw and catch TestException and IOException
    The program is not catching the exceptions however I have no errors to go by either.
    */


    import java.io.*;
     
    public class CustomTesterApp
    {
        public static void main(String[] args) throws TestException, IOException
        {
            Method1();
        }
     
        public static void Method1() throws TestException
        {
            Method2();
        }
     
        public static void Method2() throws TestException
        {
            Method3();
        }
     
        public static void Method3() throws TestException
        {
            Method3 m = null;
            m = getTestException(m);
        }
     
        private static Method3 getTestException(Method3 m) throws TestException {
            return null;
     
     
        }
        public static String TestException(String String)
        {
            try
            {
                String = TestException(String);
                String getMethod = null;
                return getMethod;
            }
            catch (Exception e)
            {
                System.err.println("error");    
            }
            return null;
        }
    }
        class TestException extends Exception //first part I have done there are no errors!!!!!!!!!!
            {
               public TestException()
               {
               }
     
               public TestException (String message)
               {
                   super (message);
               }
    }

    *********************************
    above is my code
    Last edited by Norm; May 27th, 2014 at 06:28 AM. Reason: Spaces removed from code tag

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Please help with exceptions

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    the program will not catch,
    Please explain.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Please help with exceptions

    The yellow color makes the code very hard to read!!!
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Create your own Exceptions!
    By newbie in forum Java Programming Tutorials
    Replies: 3
    Last Post: September 6th, 2013, 11:51 AM
  2. [HELP] unreported exceptions
    By Paytheprice in forum Java Theory & Questions
    Replies: 3
    Last Post: January 27th, 2013, 08:01 PM
  3. UserDefined Exceptions
    By tcstcs in forum Java Theory & Questions
    Replies: 1
    Last Post: May 8th, 2012, 05:39 AM
  4. Always Catch Exceptions
    By Tjstretch in forum Java Programming Tutorials
    Replies: 2
    Last Post: October 27th, 2011, 02:26 PM
  5. throws Exceptions
    By beruska in forum Exceptions
    Replies: 1
    Last Post: October 25th, 2011, 02:25 PM