java lang reflect invocationtargetexception [message #646519] |
Sun, 26 December 2010 00:20 |
Eclipse User |
|
|
|
Hi every one;
I am working on deploying a simple online dice game as a web service through Tomcat Axis2 using "Eclipse IDE for Java Developers" i have two problems here.
1. when I use 1st Axis 2 plugin for creating an Archive file i go through all the steps successfully and in the end it also give me message that "files generated successfuly" but when i go to services folder of Axis 2 there is no AAR file exists for my project.
2. my second problem is more crucial to me when i use second plugin called "Axis2 Code Generator" for creating wsdl file from the java code i proceeds through the wizard successfully but at the last step when give the targate file name for WSDL file it gives me this error message "java lang reflect invocationtargetexception "
I have read some where that Normally "java.lang.reflect.InvocationTargetException" occurs when java compiler finds 2 different classes with same name in 2 different packages. when u r importing both classes at a time and when you r trying to create object of that class it throws "java.lang.reflect.InvocationTargetException" exception .
My code for game is as under
// Dice CLASS
import java.util.*;
public class Dice {
// Creating an object from the class "Random" to be able to use the "Random Number" generator.
Random generator = new Random();
// Public instance variable called "thro" to store in it the randomly numbers.
public int thro;
// Data member "Length", of type "Integer". To get the length of the dice.
private int length;
// get method to get the value of "Length"
public int getLength() {
return length;
}
// set method to set a value to "Length"
public void setLength(int Lng) {
length = Lng;
}
// method that'll throw the dice and get a random integer.
public int returnRandomValue()
{
// the range of the dice's numbers will be from 1 to length.
return thro = 1 + generator.nextInt( length );
}
}
// Main Class
// To be able to input data from the user.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Dice Di = new Dice();
Scanner Scan1 = new Scanner( System.in );
//Scanner Scan2 = new Scanner( System.in );
Scanner Scan3 = new Scanner( System.in );
int sum1 = 0; // This will sum all dice numbers that'll first player get.
int sum2 = 0; // This will sum all dice numbers that'll second player get.
int lng; // To store inside it the length of the dice.
//int dice;
int s;
String player1;
String player2;
System.out.println("Please, write the name of the first player: ");
player1 = Scan1.nextLine();
System.out.println("Please, write the name of the second player: ");
player2 = Scan1.nextLine();
System.out.println("Please, type the \"Length\" of the dice: ");
lng = Scan3.nextInt();
Di.setLength(lng);
System.out.println("It is your turn now " + player1 + " you'll throw 5 times 'pray to get the highest score '.\n");
for( int i = 0; i < 5; i++ )
{
s = Di.returnRandomValue();
System.out.println("You got: " + s);
sum1 = sum1 + s;
}
System.out.println("It is your turn now " + player2 + " you'll throw 5 times 'pray to get the highest score '.\n");
for( int j = 0; j < 5; j++ )
{
s = Di.returnRandomValue();
System.out.println("You got: " + s);
sum2 = sum2 + s;
}
System.out.println(player1 + ", you got a sum of " + sum1 + " and " + player2 + ", got a sum of " + sum2);
if(sum1 > sum2)
{
System.out.println(player1 + ", Congratulation! you won .");
}
else
if(sum2 > sum1)
{
System.out.println(player2 + ", Congratulation! you won .");
}
else
if(sum2 == sum1)
{
System.out.println(player2 + ", and " + player2 + " you both played a nice game, you two equal in the luck .");
}
}
}
I m new to java please help me out with the code i will be highly grateful to you.
Best Regards.
Ali
|
|
|
Powered by
FUDForum. Page generated in 0.03890 seconds