Solved

Java RMI Exception Problem

Posted on 2009-04-09
9
462 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
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
 
LVL 12

Expert Comment

by:basav_com
ID: 24113837
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now