Hi,
I have a .class file sitting on my computer and i want to run it sometimes on someone else's computer, but i can only execute my program with the javawrapper command. If i use the regular java command, then i get this output:
Code:
Exception in thread "main" java.lang.NoClassDefFoundError: /home/brian/Desktop/Horserace10/class
what does this mean??
another thing is i want to package this file into a jar file to make it less troublesome, but i have read all the tutorials and still have no clue what i have to do. Do i have to package all the things i imported like java.io.* with the package? and if so, do i have to modify my code to make it use the jar file resources?
here is my code if it helps:
Code:
import java.io.*;
import java.util.*;
public class Horserace10
{
static Random gen = new Random();
public static void fx1()
{
int horse[] = new int[10];
int x, y, rand, a, p, d, z;
String n, pt, h;
Scanner p1, p2, p1h, p1b, p2h, p2b, hold;
horse[0] = 0;
horse[1] = 0;
horse[2] = 0;
horse[3] = 0;
horse[4] = 0;
horse[5] = 0;
horse[6] = 0;
horse[7] = 0;
horse[8] = 0;
horse[9] = 0;
rand = gen.nextInt(300);
System.out.print("Welcome to the Horse Race Game!" + "\n\n");
System.out.print("Enter Player 1's name" + "\n\n");
p1 = new Scanner(System.in);
n = p1.nextLine();
System.out.print("\n\nEnter Player 2's name" + "\n\n");
p2 = new Scanner(System.in);
pt = p2.nextLine();
System.out.print("\nEnter the horse number " + n + " wants to bet on" + " (1 - 10)" + "\n\n#");
p1h = new Scanner(System.in);
x = p1h.nextInt();
System.out.print("\nEnter how much money " + n + " wants to bet on Horse #" + x + "\n\n$");
p1b = new Scanner(System.in);
y = p1b.nextInt();
System.out.print("\nEnter the horse number " + pt + " wants to bet on\n\n#");
p2h = new Scanner(System.in);
p = p2h.nextInt();
System.out.print("\nEnter how much money " + pt + " wants to bet on Horse #" + p + " \n\n$");
p2b = new Scanner(System.in);
d = p2b.nextInt();
System.out.print("\nThe race has started!!, Press enter to continue the race");
a = rand + y + d;
z = rand + d + y;
do
{
System.out.print("\n");
for (int track = 0; track < 10; track++)
{
System.out.print("\n\n|");
for (int i = 0; i < 75; i++)
{
if (i != horse[track])
{
System.out.print("-");
}
else
{
System.out.print(track + 1);
}
}
System.out.print("|");
}
hold = new Scanner(System.in);
h = hold.nextLine();
horse[0] += gen.nextInt(3) + 1;
horse[1] += gen.nextInt(3) + 1;
horse[2] += gen.nextInt(3) + 1;
horse[3] += gen.nextInt(3) + 1;
horse[4] += gen.nextInt(3) + 1;
horse[5] += gen.nextInt(3) + 1;
horse[6] += gen.nextInt(3) + 1;
horse[7] += gen.nextInt(3) + 1;
horse[8] += gen.nextInt(3) + 1;
horse[9] += gen.nextInt(3) + 1;
}
while (horse[0] <= 75 && horse[1] <= 75 && horse[2] <= 75 && horse[3] <= 75 && horse[4] <= 75 && horse[5] <= 75 && horse[6] <= 75 && horse[7] <= 75 && horse[8] <= 75 && horse[9] <= 75);
if (horse[0] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 won the race!!");
}
if (horse[1] > 75 && horse[0] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 won the race!!");
}
if (horse[2] > 75 && horse[1] < 75 && horse[0] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 won the race!!");
}
if (horse[3] > 75 && horse[1] < 75 && horse[2] < 75 && horse[0] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 won the race!!");
}
if (horse[4] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[0] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 won the race!!");
}
if (horse[5] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[0] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 6 won the race!!");
}
if (horse[6] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 7 won the race!!");
}
if (horse[7] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[0] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 8 won the race!!");
}
if (horse[8] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[0] < 75 && horse[9] < 75)
{
System.out.print(" Horse 9 won the race!!");
}
if (horse[9] > 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[0] < 75)
{
System.out.print(" Horse 10 won the race!!");
}
if (horse[0] > 75 && horse[1] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 2 tied!!");
}
if (horse[0] > 75 && horse[2] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 3 tied!!");
}
if (horse[0] > 75 && horse[3] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 4 tied!!");
}
if (horse[0] > 75 && horse[4] > 75 && horse[2] < 75 && horse[3] < 75 && horse[1] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 5 tied!!");
}
if (horse[0] > 75 && horse[5] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[1] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 6 tied!!");
}
if (horse[0] > 75 && horse[6] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[1] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 7 tied!!");
}
if (horse[0] > 75 && horse[7] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[1] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 8 tied!!");
}
if (horse[0] > 75 && horse[8] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[1] < 75 && horse[9] < 75)
{
System.out.print(" Horse 1 and 9 tied!!");
}
if (horse[0] > 75 && horse[9] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[1] < 75)
{
System.out.print(" Horse 1 and 10 tied!!");
}
if (horse[1] > 75 && horse[2] > 75 && horse[0] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 3 tied!!");
}
if (horse[1] > 75 && horse[3] > 75 && horse[2] < 75 && horse[0] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 4 tied!!");
}
if (horse[1] > 75 && horse[4] > 75 && horse[2] < 75 && horse[3] < 75 && horse[0] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 5 tied!!");
}
if (horse[1] > 75 && horse[5] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[0] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 6 tied!!");
}
if (horse[1] > 75 && horse[6] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 7 tied!!");
}
if (horse[1] > 75 && horse[7] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[0] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 8 tied!!");
}
if (horse[1] > 75 && horse[8] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[0] < 75 && horse[9] < 75)
{
System.out.print(" Horse 2 and 9 tied!!");
}
if (horse[1] > 75 && horse[9] > 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[0] < 75)
{
System.out.print(" Horse 2 and 10 tied!!");
}
if (horse[2] > 75 && horse[3] > 75 && horse[1] < 75 && horse[0] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 4 tied!!");
}
if (horse[2] > 75 && horse[4] > 75 && horse[1] < 75 && horse[3] < 75 && horse[0] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 5 tied!!");
}
if (horse[2] > 75 && horse[5] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[0] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 6 tied!!");
}
if (horse[2] > 75 && horse[6] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 7 tied!!");
}
if (horse[2] > 75 && horse[7] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[0] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 8 tied!!");
}
if (horse[2] > 75 && horse[8] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[0] < 75 && horse[9] < 75)
{
System.out.print(" Horse 3 and 9 tied!!");
}
if (horse[2] > 75 && horse[9] > 75 && horse[1] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[0] < 75)
{
System.out.print(" Horse 3 and 10 tied!!");
}
if (horse[3] > 75 && horse[4] > 75 && horse[2] < 75 && horse[1] < 75 && horse[0] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 5 tied!!");
}
if (horse[3] > 75 && horse[5] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[0] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 6 tied!!");
}
if (horse[3] > 75 && horse[6] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 7 tied!!");
}
if (horse[3] > 75 && horse[7] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[6] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 8 tied!!");
}
if (horse[3] > 75 && horse[8] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[0] < 75 && horse[7] < 75 && horse[6] < 75 && horse[9] < 75)
{
System.out.print(" Horse 4 and 9 tied!!");
}
if (horse[3] > 75 && horse[9] > 75 && horse[2] < 75 && horse[1] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[0] < 75)
{
System.out.print(" Horse 4 and 10 tied!!");
}
if (horse[4] > 75 && horse[5] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 and 6 tied!!");
}
if (horse[4] > 75 && horse[6] > 75 && horse[5] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[0] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 and 7 tied!!");
}
if (horse[4] > 75 && horse[7] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[6] < 75 && horse[5] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 and 8 tied!!");
}
if (horse[4] > 75 && horse[8] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[6] < 75 && horse[7] < 75 && horse[5] < 75 && horse[9] < 75)
{
System.out.print(" Horse 5 and 9 tied!!");
}
if (horse[4] > 75 && horse[9] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[6] < 75 && horse[7] < 75 && horse[8] < 75 && horse[5] < 75)
{
System.out.print(" Horse 5 and 10 tied!!");
}
if (horse[5] > 75 && horse[6] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[7] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 6 and 7 tied!!");
}
if (horse[5] > 75 && horse[7] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[6] < 75 && horse[8] < 75 && horse[9] < 75)
{
System.out.print(" Horse 6 and 8 tied!!");
}
if (horse[5] > 75 && horse[8] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[7] < 75 && horse[6] < 75 && horse[9] < 75)
{
System.out.print(" Horse 6 and 9 tied!!");
}
if (horse[5] > 75 && horse[9] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[7] < 75 && horse[8] < 75 && horse[6] < 75)
{
System.out.print(" Horse 6 and 10 tied!!");
}
if (horse[7] > 75 && horse[8] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[9] < 75)
{
System.out.print(" Horse 8 and 9 tied!!");
}
if (horse[7] > 75 && horse[9] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[8] < 75)
{
System.out.print(" Horse 8 and 10 tied!!");
}
if (horse[8] > 75 && horse[9] > 75 && horse[0] < 75 && horse[1] < 75 && horse[2] < 75 && horse[3] < 75 && horse[4] < 75 && horse[5] < 75 && horse[6] < 75 && horse[7] < 75)
{
System.out.print(" Horse 9 and 10 tied!!");
}
if (horse[0] > 75 && x == 1 || horse[1] > 75 && x == 2 || horse[2] > 75 && x == 3 || horse[3] > 75 && x == 4 || horse[4] > 75 && x == 5 || horse[5] > 75 && x == 6 || horse[6] > 75 && x == 7 || horse[7] > 75 && x == 8 || horse[8] > 75 && x == 9 || horse[9] > 75 && x == 10)
{
a += y;
System.out.print("\n\n " + n + " has bet on the right horse! " + n + " won $" + a + "!!");
}
if (horse[0] < 75 && x == 1 || horse[1] < 75 && x == 2 || horse[2] < 75 && x == 3 || horse[3] < 75 && x == 4 || horse[4] < 75 && x == 5 || horse[5] < 75 && x == 6 || horse[6] < 75 && x == 7 || horse[7] < 75 && x == 8 || horse[8] < 75 && x == 9 || horse[9] < 75 && x == 10)
{
a -= y;
System.out.print("\n\n " + n + " has bet on the wrong horse! " + n + " lost $" + y + "!!");
}
if (x > 10 || x < 1)
{
System.out.print("\n\n " + n + " bet on a non-exsisting horse, so " + n + " lost $" + y + "!!");
}
if (horse[0] > 75 && p == 1 || horse[1] > 75 && p == 2 || horse[2] > 75 && p == 3 || horse[3] > 75 && p == 4 || horse[4] > 75 && p == 5 || horse[5] > 75 && p == 6 || horse[6] > 75 && p == 7 || horse[7] > 75 && p == 8 || horse[8] > 75 && p == 9 || horse[9] > 75 && p == 10)
{
a += d;
System.out.print("\n\n " + pt + " has bet on the right horse! " + pt + " won $" + z + "!!");
}
if (horse[0] < 75 && p == 1 || horse[1] < 75 && p == 2 || horse[2] < 75 && p == 3 || horse[3] < 75 && p == 4 || horse[4] < 75 && p == 5 || horse[5] < 75 && p == 6 || horse[6] < 75 && p == 7 || horse[7] < 75 && p == 8 || horse[8] < 75 && p == 9 || horse[9] < 75 && p == 10)
{
a -= d;
System.out.print("\n\n " + pt + " has bet on the wrong horse! " + pt + " lost $" + d + "!!");
}
if (p > 10)
{
System.out.print("\n\n " + pt + " bet on a non-exsisting horse, so " + pt + " lost $" + d + "!!");
}
}
public static void main(String[] args)
{
for (int lo = 0; lo < 10; lo++)
{
int ch;
Scanner choice;
fx1();
System.out.print("\n\n Nice Race!! If you want to play again, type 1 or type 2 to exit\n:");
choice = new Scanner(System.in);
ch = choice.nextInt();
if (ch == 1)
{
System.out.print("\n\nHorse Race 10 is restarting...Done\n\n\n");
lo = 2;
}
if (ch == 2)
{
System.out.print("\n\nHorse Race 10 is exiting... :(\n\n\nThanks for playing Horse Race 10!\n\n");
lo = 15;
}
}
}
}
Thanks,
Rabbit2345