Solved

Java RMI Exception Problem

Posted on 2009-04-09
9
471 Views
Last Modified: 2013-12-14
I have a GUI which needs to pass variables to a class. If I try to make an instance of that class 'Asb asb = new Asb();'
 I get the error saying "unreported exception java.rmi.RemoteException; must be caught or declared to be thrown".
public class Asb extends UnicastRemoteObject implements Publisher,
		 Serializable
 
{
 
public Asb() throws RemoteException
     
   {
        
super();
            
     }
 
}

Open in new window

0
Comment
Question by:namsu55
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 13

Expert Comment

by:MicheleMarcon
ID: 24113663
As you have declared, the Asb() constructor throws RemoteException.

You need to do this:

try{
Asb asb = new Asb();
//your code here
}catch (RemoteException e){
//something has gone wrong, you can put debug code or fix the problem.
System.out.println("Something bad happened!");
}
0
 

Author Comment

by:namsu55
ID: 24113805
Yeah that works, can you give me an example of system.out.println, where if connection is not made or not present (rmiregistry not turned on) throws an exception. From within the ABS class.
0
 
LVL 12

Expert Comment

by:basav_com
ID: 24113821
throw(e);
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 12

Expert Comment

by:basav_com
ID: 24113837
0
 

Author Comment

by:namsu55
ID: 24113842
try{
Asb asb = new Asb();
//your code here
}catch (RemoteException e){
//something has gone wrong, you can put debug code or fix the problem.
System.out.println("Something bad happened!");
}
throw(e);

That doesnt work it says incompatible types.
0
 
LVL 12

Expert Comment

by:basav_com
ID: 24113845
Actually you can declare the class throws exception:
See this example is very close to your question:
http://www.experts-exchange.com/Programming/Languages/Java/Q_20985361.html
0
 
LVL 12

Accepted Solution

by:
basav_com earned 250 total points
ID: 24113874
try{
Asb asb = new Asb();
//your code here
}catch (RemoteException e){
//something has gone wrong, you can put debug code or fix the problem.
System.out.println("Something bad happened!");
throw(e);    ---->  You messed up the brackets
}
0
 

Author Comment

by:namsu55
ID: 24113897
It now says what it said before : "unreported exception java.rmi.RemoteException; must be caught or declared to be thrown".
0
 
LVL 17

Assisted Solution

by:Thomas4019
Thomas4019 earned 250 total points
ID: 24117024
I just use e.printStackTrace(); This causes it to print the Exception to the Console window.
try{
Asb asb = new Asb();
//your code here
}catch (RemoteException e){
e.printStackTrace();
}

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question