How to throw Exception in Thread.run() method

I want to throw exception in Thread.run() method. How can I do that ?
If I try to compile the Code given below, it does not allow me to compile :
public class ThreadTest {
     public static void main(String[] args) {
     ThreadTest.DyingThread t = new DyingThread();
     t.start();
     static class DyingThread extends Thread {
     public void run() {
     try {
               //some code that may throw some exception here
          } catch (Exception e) {
          throw e;//Want to throw(pass) exception to caller
}

(a) in JDK 1.4+, wrap your exception in RuntimeException:
catch (Exception e)
throw new RuntimeException(e);
[this exception will be caught by ThreadGroup.uncaughtException() of this thread's parent thread group]
In earlier JDKs, use your own wrapping unchecked exception class.
(b) if you know what you are doing, you can make any Java method throw any exception using Thread.stop(Throwable) regardless of what it declares in its "throws" declaration.

Similar Messages

  • How to get value from Thread Run Method

    I want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that it seems that scope of the variable gets lost resulting to null value in the called method/class..
    How can I get the variable with the value?
    This is sample code:
    public class SampleSynchronisation
    public static void main(String df[])
    sampleThread sathr= new sampleThread();
    sathr.start();
    System.out.println("This is the value from the run method "+sathr.x);
    /* I should get Inside the run method::: But I get only Inside */
    class sampleThread extends Thread
         public String x="Inside";
         public void run()
              x+="the run method";

    I think this is what you're looking for. I hold up main(), waiting for the results to be concatenated to the String.
    public class sampsynch
        class SampleThread extends Thread
         String x = "Inside";
         public void run() {
             x+="the run method";
             synchronized(this) {
              notify();
        public static void main(String[] args) throws InterruptedException {
         SampleThread t = new sampsynch().new SampleThread();
         t.start();
         synchronized(t) {
             t.wait();
         System.out.println(t.x);
    }

  • How to throw exception in run() method of Runnable?

    Hi, everyone:
    I want to know how to throw exception in run() method of interface Runnable. Since there is no throwable exception declared in run() method of interface Runnable in Java API specification.
    Thanks in advance,
    George

    Thanks, jfbriere.
    I must add though that if your run() methodis
    executed after a call to Thread.start(), then
    it is not a good choice to throw anyRuntimeException
    from the run() method.
    The reason is that the thrown exception won't be
    handled appropriately by a try-catch block.Why do you say that "the thrown exception won't be
    handled appropriately by a try-catch block"? Can you
    explain it in more detail?
    regards,
    George
    Because the other thread runs concurrently with and independently of the parent thread, there's no way you can write a try/catch that will handle the new thread's exception: try {
        myThread.start();
    catch (TheExceptionYouWantToThrowFromRun exc) {
        handle it
    do the next thing This won't work because the parent thread just continues on after myThread.start(). Start() doesn't throw the exception--run() does. And our parent thread here has lost touch with the child thread--it just moves on to "do the next thing."
    Now, you can do some exception handling with ThreadGroup and uncaughtException(), but make sure you understand why the above won't work, in case that was what you were planning to do.

  • Throw exceptions from threads?

    Is it possible to throw exceptions from threads since I can't add the throws statement to the run method I don't know how I could do it...
    Any help greatly appriciated!
    Cya

    Is it possible to throw exceptions from threads since
    I can't add the throws statement to the run method I
    don't know how I could do it...
    Any help greatly appriciated!
    CyaYou can't throw checked exceptions, because obviously the code responsible for invoking the run() method wouldn't know what to do with it, and you wouldn't be the one to catch them. You can however throw unchecked exceptions (such as those based on RuntimeException).

  • Thread.run() method..

    I was wondering how the "Thread.run()" method get called. I started with "Thread.start()" and found it calls the "Thread.start0()" which is a native method.
    I downloaded the JDK 5 source code and went to "j2se\src\share\native\java\lang\Thread.c". In "Thread.c" I found a mapping of "start0()" with "JVM_StartThread".
    After that I opened the "hotspot\src\share\vm\prims\jvm.cpp". From line no 2257 to 2316 I saw the implementation of "JVM_StartThread".
    In side "JVM_StartThread", I saw there is a call to "Thread::start(native_thread)" and opened the "hotspot\src\share\vm\runtime\Thread.cpp". In "Thread.start()" method there is a call to "os::start_thread(thread);".
    In "hotspot\src\share\vm\runtime\os.cpp" the "os::start_thread()" calls the "pd_start_thread(thread);" method. But I did not get the "pd_start_thread(thread);" method in os.cpp.
    Note: I am java programmer and hardly understand the C/C++ languages. But had a doubt how the run() method get called and how the Thread.start() method works. But I got stuck here.
    Kindly help me to know how the flow goes, when we call the Thread.start() and how the run() method is linked to it.

    But I did not see anything in the os.cpp. In fact i did not find the "pd_start_thread(thread);" .
    void os::start_thread(Thread* thread) {
      // guard suspend/resume
      MutexLockerEx ml(thread->SR_lock(), Mutex::_no_safepoint_check_flag);
      assert(thread->is_baby_thread(), "thread has started");
      thread->clear_is_baby_thread();
      OSThread* osthread = thread->osthread();
      // A thread may be suspended in the presence of the profiler.
      // Only start thread when it's not suspended.
      osthread->set_state(RUNNABLE);
      if (!thread->is_vm_suspended()) {
        pd_start_thread(thread);
    }

  • How to calculate number of threads  running  on Windows 2000 terminal?

    How to calculate number of threads running on Windows 2000 terminal for the oracle process?
    I have installed Oracle 9i DataBase with 6 patch(9.2.0.6.0) on Windows 2000 Terminal.
    But,after database is started up, when i check up the sessions in v$session view.
    It is showing like for SYSTEM osuser alone, 10 ORACLE.EXE sessions running on this server machine in active state.
    Why it is creating 10 ORACLE.EXE sessions for a single Oracle Server.
    This is the output of v$session view.
    SQL> select terminal,osuser,status,sid,serial#,program from v$session;
    TERMINAL OSUSER STATUS SID SERIAL# PROGRAM
    IMGDBSVR SYSTEM ACTIVE 1 1 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 2 1 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 3 1 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 4 1 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 5 1 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 6 1 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 7 1 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 8 1 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 9 1 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 10 1 ORACLE.EXE
    SUGANTHI_DBA suganthi ACTIVE 11 91 sqlplusw.exe
    11 rows selected.
    SQL>

    This is how i have related these two views:
    SQL> select s.terminal,s.osuser,s.status,s.paddr s_paddr,b.paddr p_paddr,s.program
    2 from v$session s,gv$bgprocess b
    3 where s.paddr=b.paddr;
    TERMINAL OSUSER STATUS S_PADDR P_PADDR PROGRAM
    IMGDBSVR SYSTEM ACTIVE 33AF2270 33AF2270 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 33AF2654 33AF2654 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 33AF2A38 33AF2A38 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 33AF2E1C 33AF2E1C ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 33AF3200 33AF3200 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 33AF35E4 33AF35E4 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 33AF39C8 33AF39C8 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 33AF3DAC 33AF3DAC ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 33AF4958 33AF4958 ORACLE.EXE
    IMGDBSVR SYSTEM ACTIVE 33AF4D3C 33AF4D3C ORACLE.EXE
    10 rows selected.
    SQL>
    Here, It shows 10 sessions are running.
    Whether this means 10 threads are running on the particular server or not?

  • How to pass the caught exception in Thread.run back to the main program?

    I have following three Java files (simplified from a real world application I am developing, see files at the end of this posting):
    1. ThreadTest.java: The main program that invokes the Manager.run()
    2. Manager.java: The manager that creates a thread to execute the Agent.run() for each agent
    3. Agnet.java: The run() method can throw Exception
    My goal is twofold:
    1. To execute the run() method of an Agent in a thread (the reason for this is there are many Agents all managed by a Manager)
    2. To catch the exception thrown by Agent.run() in the main program, ThreadTest.main() -- so the main program can alert the exceptions
    My problem:
    Bottomline: I cannot pass the exception thrown by Agent.run() in the Thread.run() back to the main program.
    Explanation:
    The signature of Thread.run() (or Runnable.run()) is
    public void run();
    Since it does not have a throws clause, so I have to try/catch the Agent.run(), and rethrow a RuntimeException or Error. However, this RuntimeException or Error will not be caught by the main program.
    One work-around:
    Subclass the ThreadGroup, override the ThreaGroup.uncaughtException() methods, and spawn the threads of this group. However, I have to duplicate the logging and exception alerts in the uncaughtException() in addition to those already in the main program. This makes the design a bit ugly.
    Any suggestions? Am I doing this right?
    Thanks,
    Xiao-Li "Lee" Yang
    Three Java Files:
    // Agent.java
    public class Agent {
    public void run() throws Exception {
    throw new Exception("Test Exception"); // Agent can throw execptions
    // Manager.java
    public class Manager {
    public void run() throws Exception {
    try {         // <===  This try/catch is virtually useless: it does not catch the RuntimeException
    int numberOfAgents = 1;
    for (int i = 0; i < numberOfAgents; i++) {
    Thread t = new
    Thread("" + i) {
    public void run() {
    try {
    new Agent().run();
    } catch (Exception e) {
    throw new RuntimeException(e); // <=== has to be RuntimeException or Error
    t.start();
    } catch (Exception e) {
    throw new Exception(e); // <== never got here
    // ThreadTest.java
    public class ThreadTest {
    public static void main(String[] args) {   
    try {
    Manager manager = new Manager();
    manager.run();
    } catch (Throwable t) {
    System.out.println("Caught!"); // <== never got here
    t.printStackTrace();

    The problem is, where could you catch it anyway?
    try {
    thread.start();
    catch(SomeException e) {
    A thread runs in a separate, er, thread, that the catch(SomeException) isn't running within. Get it?
    Actually the Thread class (or maybe ThreadGroup or whatever) is the one responsible for invoking the thread's run() method, within a new thread. It is the one that would have to catch and deal with the exception - but how would it? You can't tell it what to do with it, it (Thread/ThreadGroup) is not your code.

  • How can I get the variable with the value from Thread Run method?

    We want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that scope of the variable gets lost resulting to null value in the called method/class..
    How can I get the variable with the value?
    This is sample code:
    public class SampleSynchronisation
         public static void main(String df[])
    sampleThread sathr= new sampleThread();
    sathr.start();
    System.out.println("This is the value from the run method "+sathr.x);
    // I should get Inside the run method::: But I get only Inside
    class sampleThread extends Thread
         public String x="Inside";
         public void run()
              x+="the run method";
    NB: if i write the variable in to a file I am able to read it from external method. This I dont want to do

    We want to access a variable from the run method of a
    Thread externally in a class or in a method. I presume you mean a member variable of the thread class and not a local variable inside the run() method.
    Even
    though I make the variable as public /public static, I
    could get the value till the end of the run method
    only. After that scope of the variable gets lost
    resulting to null value in the called method/class..
    I find it easier to implement the Runnable interface rather than extending a thread. This allows your class to extend another class (ie if you extend thread you can't extend something else, but if you implement Runnable you have the ability to inherit from something). Here's how I would write it:
    public class SampleSynchronisation
      public static void main(String[] args)
        SampleSynchronisation app = new SampleSynchronisation();
      public SampleSynchronisation()
        MyRunnable runner = new MyRunnable();
        new Thread(runner).start();
        // yield this thread so other thread gets a chance to start
        Thread.yield();
        System.out.println("runner's X = " + runner.getX());
      class MyRunnable implements Runnable
        String X = null;
        // this method called from the controlling thread
        public synchronized String getX()
          return X;
        public void run()
          System.out.println("Inside MyRunnable");
          X = "MyRunnable's data";
      } // end class MyRunnable
    } // end class SampleSynchronisation>
    public class SampleSynchronisation
    public static void main(String df[])
    sampleThread sathr= new sampleThread();
    sathr.start();
    System.out.println("This is the value from the run
    method "+sathr.x);
    // I should get Inside the run method::: But I get
    only Inside
    class sampleThread extends Thread
    public String x="Inside";
    public void run()
    x+="the run method";
    NB: if i write the variable in to a file I am able to
    read it from external method. This I dont want to do

  • Keytool throwing  Exception in thread "main" java.lang.OutOfMemoryError:

    Hello all.
    I am unable to run keytool as it throws the following error. I am running Vista(x86),JDK 1.6 with a system with 4G of ram.
    Any idea's how i would solve this? I have tried installing other JDK's with the same results.
    Thanks in advance.
    C:\Users\Gav>"c:\Program Files\Java\jdk1.6.0_07\bin"\keytool -genkey -alias andr
    oiddebugkey -keyalg RSA -validity 365 -keypass android -keystore debug.keystore
    -storepass android
    What is your first and last name?
      [Unknown]:  a
    What is the name of your organizational unit?
      [Unknown]:  b
    What is the name of your organization?
      [Unknown]:  c
    What is the name of your City or Locality?
      [Unknown]:  d
    What is the name of your State or Province?
      [Unknown]:  e
    What is the two-letter country code for this unit?
      [Unknown]:  fs
    Is CN=a, OU=b, O=c, L=d, ST=e, C=fs correct?
      [no]:  yes
    Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
            at java.io.WinNTFileSystem.list(Native Method)
            at java.io.File.list(File.java:973)
            at sun.security.provider.SeedGenerator$1.run(SeedGenerator.java:166)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.security.provider.SeedGenerator.getSystemEntropy(SeedGenerator.java:146)
            at sun.security.provider.SecureRandom.engineNextBytes(SecureRandom.java:170)
            at java.security.SecureRandom.nextBytes(SecureRandom.java:433)
            at java.math.BigInteger.randomBits(BigInteger.java:475)
            at java.math.BigInteger.<init>(BigInteger.java:464)
            at java.math.BigInteger.largePrime(BigInteger.java:596)
            at java.math.BigInteger.probablePrime(BigInteger.java:538)
            at sun.security.rsa.RSAKeyPairGenerator.generateKeyPair(RSAKeyPairGenerator.java:105)
            at java.security.KeyPairGenerator$Delegate.generateKeyPair(KeyPairGenerator.java:656)
            at sun.security.x509.CertAndKeyGen.generate(CertAndKeyGen.java:131)
            at sun.security.tools.KeyTool.doGenKeyPair(KeyTool.java:1156)
            at sun.security.tools.KeyTool.doCommands(KeyTool.java:786)
            at sun.security.tools.KeyTool.run(KeyTool.java:172)
            at sun.security.tools.KeyTool.main(KeyTool.java:166)

    See http://bugs.sun.com/bugdatabase/view_bug.do;?bug_id=6474350
    It seems that one way used by SecureRandom to gather entropy is to scan the directory pointed at by java.io.tmpdir. If it is very full, it runs out of memory. Clean you Local Settings\Temp directory.

  • Throwing exceptions in threads

    I made a thread class that uses a BufferedReader object wrapped in a InputStream and Socket object inside the run() method that uses the command this.input.readline().
    The only problem is that in order to use this method, I need to throw java.io.IOException. When I try and do this, it says:
    "The method void run() declared in class InputThread cannot overide the method of the same signature declared in class java.land.Thread. Their throws clauses are incompatible."
    Here is my original code:
    class InputThread extends Thread {
         BufferedReader input;
         public InputThread(BufferedReader input) {
              this.input = input;
         public void run() {
              String intext = "";
              while (true) {
                   intext = this.input.readLine();
                   if (intext != "") {
                        System.out.println("Thread received: " + intext);
    }How can I still use the this.input.readLine() function in the InputThread class?
    (I already tried "public void run() throws java.io.IOException {")
    Thanks!

    The run method should handle all exceptionn that could occur in the
    contained code. There's als no point in propagating a (checked) exception
    to a higher level by wrapping it in an unchecked exception like RuntimeException
    which is not commited to be declared in the throws clause.
    So ...
    public void run() {   
       try {
       } catch (Exception ex) {
          throw new RuntimeException("bla", ex);
    } ...would compile. BUT where would you catch the exception??? Don't be mistaken,
    but the exception is never propagated to the code that started the thread!!!
    Threads are the end points for exceptions because they run parallel to other code.
    In my opinion the best and most correct code would be:
    class InputThread extends Thread {
         BufferedReader input;
         public InputThread(BufferedReader input) {
              this.input = input;
         public void run() {
              String intext = "";
              try {
                  while (true) {
                   intext = this.input.readLine();
                   if (intext != "") {
                        System.out.println("Thread received: " + intext);
                    } catch (IOEXception ex) {
                        // log exception and die gracefully
    }

  • How to resolve Exception in thread "main" java.lang.NoSuchFieldError: strm

    Hi,
    Aplogies, if I am posting this in the wrong place, else please guide me.
    We were running JBoss server 4.2.3 GA with Java 5 Update 19 in Solaris 10.
    Details of uname command in Solaris box is,
    uname -a
    SunOS uktapp06 5.10 Generic_125100-10 sun4us sparc FJSV,GPUZC-M
    Due to performance issues we need to upgrade to latest Java [Java 6 Update 21] and when I tried to run JBoss with 64 bit mode using Java options like,
    JAVA_OPTS="*-d64* -Xms3g -Xmx3g -XX:ThreadStackSize=512 -XX:+UseParallelGC -XX:MaxPermSize=256m -XX:NewRatio=2"
    I get the below error,
    Exception in thread "main" java.lang.NoSuchFieldError: strm
            at java.util.zip.Inflater.initIDs(Native Method)
            at java.util.zip.Inflater.<clinit>(Inflater.java:68)
            at java.util.zip.ZipFile.getInflater(ZipFile.java:266)
            at java.util.zip.ZipFile.getInputStream(ZipFile.java:212)
            at java.util.zip.ZipFile.getInputStream(ZipFile.java:180)
            at java.util.jar.JarFile.hasClassPathAttribute(JarFile.java:465)
            at java.util.jar.JavaUtilJarAccessImpl.jarFileHasClassPathAttribute(JavaUtilJarAccessImpl.java:21)
            at sun.misc.URLClassPath$JarLoader.getClassPath(URLClassPath.java:903)
            at sun.misc.URLClassPath.getLoader(URLClassPath.java:302)
            at sun.misc.URLClassPath.getResource(URLClassPath.java:168)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)I have posted this at JBoss Forum here, http://community.jboss.org/message/553489
    and got a response that we need to reinstall Java 6 Update 21 in Solaris
    However my System admin verified and said there are no issues in Java installation.
    I could run a HelloWorld sample program using the same Java options [with -d64 flag] and that runs perfectly.
    I do not have any clue because I do not think there is any issues in the JBoss server
    From the above trace, it is failing at a native call and not picking up the required libraries.
    Please also let me know the below
    1. Whether I need to set any environment variables?
    2. Whether the installation would have been corrupted and we need to reinstall?
    Thanks,
    Prabhu

    Hi Franco,
    Yes, I solved that by reinstalling Java 6 Update 21.
    There are three versions for Solaris namely, SPARC, x64 and x86. Our platform is SPARC and I think System admin has installed the wrong version instead of installing SPARC version of Java.
    After installing SPARC version of Java this got resolved. And I confirmed everything is fine by running a small program as below. You can run this program from command line using the -d64 flag. If the installation is wrong you will get the same exception as I mentioned.
    public class Analyzer {
          public static void main(String args[]) throws Exception{
               InputStream fin = new FileInputStream(args[0]);
               int iSize = fin.available();
               byte mvIn[] = new byte[iSize];
               fin.read(mvIn,0,iSize);
               fin.close();
               String strText = new String(mvIn);
               PrintStream fout = new PrintStream(new FileOutputStream(args[0]+".csv"));
               fout.println("Before,After,Seconds");
               Pattern p = Pattern.compile("\\[(?:Full |)GC (\\d*)K->(\\d*)K\\(\\d*K\\), ([\\d.]*) secs\\]");
               Matcher m = p.matcher(strText);
               while(m.find()){
                    fout.println(m.group(1)+ "," + m.group(2) + "," + m.group(3));
               fout.close();
    }Hope this helps.
    Regards,
    Prabhu

  • Throwing exceptions in an actionPerformed method

    it tells me I can't do it
    is there a way to get around this?
    I'm reading a file inside the method so thats the exception in case it matters

    It's not in swing.. i'm making it on eclipse
    public void actionPerformed(ActionEvent e) {
    read();
    //do some stuff
    private void read() throws Exception{
    BufferedReader reader = new BufferedReader(new FileReader(file));
    //read some stuff
    thats the lines that are causing me trouble, the only thing i've learned to do is throw exceptions in read() though I know there are better ways such as try{ and catching specific exception I don't know how to use them.
    when I try to make actionPerformed throw Exceptions like I did to read() it says:
    Exception Exception is not compatible with throws clause in ActionListener.actionPerformed(Action Event)
    So... I don't know what to do and this is the final step in a program i've been making for a while now.

  • How to throw exception..?

    class A
    void execute() throws Exception
    int i=10/0;
    public static void main(String args[])
    try
      new A().execute();
    catch(Exception e)
    System.out.println(e);
    (or)
    class A
    void execute() throws Exception
    try
    int i=10/0;
    catch(Exception e)
    throw e;
    public static void main(String args[])
    try
      new A().execute();
    catch(Exception e)
    System.out.println(e);
    }hi i want to knw which form of throwing of exception is best from the above two program... and also tell me the reason pls... can anyone give the solution.....

    There are two general classes of exceptions in java, often called checked and unchecked.
    The exception thrown by zero divide, in your example, is a RuntimeException and doesn't require a throws clause.
    Most exceptions are throw with a throw statement, but a few kinds are throw directly by the JVM, zero divide or NullPointerExceptions being examples.
    If you need to throw an exception you typically create an exception class of your own, by extending the Exception class. That way you can have a catch clause that catches just that one kind of exception and your program can act accordingly.

  • How to throws exception from subprocess?

    Hi,
    I use subprocess in my process and I need throws exception from subprocess to my main process.
    Thanks for help.
    Jakub

    The only to throw an exception from a sub process is by leveraging the Exception event (from the event view).
    You need to throw the exception, by dragging the Exception event and choose Throw into your subprocess. Then you need to add an exception "catcher" in the parent process to catch the Exception.
    Jasmin

  • How to throw exception from Listener's Event Methods

    Hi,
    We are using Jdev 10.1.3 and I'm implementing a class that implements EntityListener and RowSetListener interfaces.
    The problem that i'm facing is when I override the event methods of the interface (Which don,t throw any exception) , I'm not able to throw any exceptions in overridden methods also. Kidnly guide me on how to achieve this...
    Sample Code :
    public class GenericHistoryViewObjectImpl extends ViewObjectImpl implements RowSetListener
    // this event is fired when a row is deleted from rowset and it registers data in history
    public void rowDeleted(DeleteEvent event)
    latestEvent = "DEL";
    try
    GenericHistoryManager.registerDataInHistory(this);
    wasLastEventExecutedSuccessfully = 1;
    catch (Exception e)
    e.printStackTrace();
    wasLastEventExecutedSuccessfully = 0;
    genericHistViewException = e;
    from The mothod public void rowDeleted(DeleteEvent event) of RowSetListener i want to throw an exception ...

    JSalonen is totally correct. I would only add that this topic, generally, exposes the differences between checked and unchecked exceptions. Unchecked exceptions extend RuntimeException or Error. Checked exceptions extend Throwable or Exception. There are important differences.
    Checked exceptions must specifically be caught or declared in a throws clause of a caller. Unchecked exceptions do not have this restriction. This means you can always 'wrap' (or throw without wrapping) an unchecked exception. Unchecked exceptions are very useful. You can use an existing unchecked exception, or create your own by extending RuntimeException or Error.
    To illustrate the difference, let's say we are creating a new user account and storing it in the database. For a checked exception, I might define DuplicateUserRegistration in case a user registers with an existing user name (a non-fatal error case that can be anticipated in system design). However, if the database was down, I would not throw SQLException (which is checked) but rather something like ResourceUnavailableError. This would be unchecked. A calling class (normally) will not be able to realistically handle a situation where the database is down, so why force that caller to either declare throws SQLException or catch SQLException for this instance?
    - Saish

Maybe you are looking for

  • How can I get my iTunes library back on my iPad?

    So, I own a Macbook and I have about 20 gigs of music on my hard drive, files are also store in iTunes Match, iCloud, etc. When I first got my iPad, I saw my entire iTunes library was also on my iPad, just not downloaded to the hd, it was apearing as

  • Game Center mixes up scores of multiple users (apple IDs)

    (New iPad, iOS6 - all apps are up to date) My son and I both have our own Apple ID. When we play games in Game Center, we use our OWN ACCOUNT. Still we get each other's scores & achievements. Example: Subway Surfers: I log on to GC using my credentia

  • Ipod touch wont turn on after update!!

    I had plugged my ipod into my computer and popped up there was an update so i did the update. Now the screen has had an apple and loading bar for the past three hours! I tried to reboot it and it just goes back to the same apple screen with loading b

  • Multi Value Recertification in Role Manager

    Hi Everybody, Is there anything(feature) called multi valued recertification in role manager(OIA). Regards, Ravindra

  • Create/View New Message

    Forgive the newby question... In the process of writing a message (Mavericks e-mail) is there a way to keep the pending message on top? If before sending the message I go to another app, then return to email, only "show all open windows" key will bri