[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Java RMI Exception Problem

Posted on 2009-04-09
9
Medium Priority
?
473 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
Industry Leaders: 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!

 
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 1000 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 1000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

649 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