Problems with compiling the BlackJackServer program
hello.
this is james mcfadden. I have developed a multiplayer BlackJack card game in Java. the game consists of six programs: BlackJack.java, BlackJackServer.java, BlackJackClient.java, Card.java, Deck.java, and Hand.java. i got most of the game code from http://www.netsoc.tcd.ie/~duncan/dev/java/games/blackjack/. When i compile the server i get the following errors (i've also included the source code in this message):
----jGRASP exec: javac -g X:\NETPROG\Assignment2\BlackJackServer.java
BlackJackServer.java:56: cannot find symbol
symbol : method getSource()
location: class BlackJack
bj.getSource();
^
BlackJack.java:176: cannot find symbol
symbol : method getCodeBase()
location: class BlackJack
card_images[current_card_loading]=getImage(getCodeBase(),"cards/"+(current_card_loading+1)+".gif");
^
BlackJack.java:197: cannot find symbol
symbol : constructor Deck(BlackJack,java.awt.Image[])
location: class Deck
deck=new Deck(this,card_images);//Create a new deck object
^
3 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
how do i go about fixing these errors?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BlackJack extends JFrame implements ActionListener,Runnable{
private Deck deck;//The deck
private Hand player_hand;//player hand
private Hand dealer_hand;//dealer hand
private JButton bHit=new JButton("Hit");
private JButton bStay=new JButton("Stay");
private JButton bRestart=new JButton("New Game");
//lets do some double buffering
Image offIm=null;
Graphics offGraphics=null;
Dimension offDimension=null;
Image[] card_images=new Image[52];
private boolean cards_loaded=false;
private int current_card_loading=0;
String message;//print a message
int width;//The width of the applet
int height;//The height of the applet
int card_width=-1;
int card_padding=-1;//How much should we pad the cards by?
private int games=-1;//How many games have been played?
public BlackJack(){
Thread card_loader=new Thread(this);
card_loader.start();
public static void main(String[] args){
JFrame frame=new JFrame("BlackJack");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500,500);
frame.setLocation(200,200);
BlackJack bj=new BlackJack();
frame.setContentPane(bj);
frame.setVisible(true);
public void newGame(){
bHit.setEnabled(true);
bStay.setEnabled(false);
player_hand=new Hand();//Create new hands
dealer_hand=new Hand();
//shuffle the deck.
deck.shuffleCards();
games++;
public void hit(){
bStay.setEnabled(true);
player_hand.addCard(deck.dealCard());
if(player_hand.getValue()>21){
message="You loose! (score:"+player_hand.getValue()+")";
//disable the hit and stay buttons...
bHit.setEnabled(false);
bStay.setEnabled(false);
return;
message="Score: "+player_hand.getValue();
public void stay(){
while(dealer_hand.getValue()<17){
dealer_hand.addCard(deck.dealCard());
if(dealer_hand.getValue()<=21&&player_hand.getValue()<dealer_hand.getValue()){
message="You loose! ("+player_hand.getValue()+" - "+dealer_hand.getValue()+")";
else if(player_hand.getValue()==dealer_hand.getValue()){
message="You draw! ("+player_hand.getValue()+")";
else{
message="You win! ("+player_hand.getValue()+" - "+dealer_hand.getValue()+")";
bHit.setEnabled(false);
bStay.setEnabled(false);
public void actionPerformed(ActionEvent e){
if(e.getSource()==bRestart){
newGame();
else if(e.getSource()==bHit){
hit();
else if(e.getSource()==bStay){
stay();
repaint();
public void paint(Graphics g){
update(g);
public void update(Graphics g){
//lets sord out double buffering
if(offGraphics==null){
offIm=createImage(getSize().width,getSize().height);
offGraphics=offIm.getGraphics();
if(!cards_loaded){
//display a message saying we're loading the cards...
offGraphics.setFont(new Font("Arial",Font.PLAIN,14));
offGraphics.setColor(new Color(171,205,239));
offGraphics.fillRect(0,0,getSize().width,getSize().height);
offGraphics.setColor(Color.black);
offGraphics.drawString("Loading cards... ",5,20);
offGraphics.drawRect(15,40,102,10);
offGraphics.drawRect(13,38,106,14);
offGraphics.setColor(new Color(171,205,239));
offGraphics.fillRect(0,0,150,35);
offGraphics.setColor(Color.black);
offGraphics.fillRect(15,40,(current_card_loading)*2,10);
offGraphics.drawString("Loading card: "+current_card_loading+1,15,20);
else{
Image currentCard;
while(card_width==-1){
card_width=deck.getCard(0).getImage().getWidth(this);
if(card_padding==-1){
card_padding=(width-(card_width*2)-4)/4;
//clear the background
offGraphics.setColor(Color.blue);
offGraphics.fillRect(0,0,width,height);
offGraphics.setColor(Color.black);
offGraphics.fillRect(1,1,width-2,height-2);
offGraphics.setColor(Color.white);
offGraphics.drawString("PLAYER:",card_padding,40);
offGraphics.drawString("DEALER:",(width/2)+card_padding,40);
offGraphics.drawString(message,5,height-20);
if(games>0){
offGraphics.drawString(games+" game(s) played...",5,height-10);
//Draw the players hand
for(int i=0;i<player_hand.getCardCount();i++){
currentCard=player_hand.getCards().getImage();
offGraphics.drawImage(currentCard,card_padding,70+(20*(i-1)),this);
//now draw the dealers hand
for(int i=0;i<dealer_hand.getCardCount();i++){
currentCard=dealer_hand.getCards()[i].getImage();
offGraphics.drawImage(currentCard,(width/2)+card_padding,70+(20*(i-1)),this);
//draw buffered image
g.drawImage(offIm,0,0,this);
public void run(){
MediaTracker t=new MediaTracker(this);
System.out.println("Frame getting cards...");
for(current_card_loading=0;current_card_loading<52;current_card_loading++){
card_images[current_card_loading]=getImage(getCodeBase(),"cards/"+(current_card_loading+1)+".gif");
if(card_images[current_card_loading]==null){
System.out.println("Null card... ["+current_card_loading+"]");
else{
t.addImage(card_images[current_card_loading],0);
try{
t.waitForID(0);
catch(InterruptedException e){
System.err.println("Interrupted waiting for images..>");
//lets show our new status
repaint();
//create the deck object now
deck=new Deck(this,card_images);//Create a new deck object
card_width=deck.getCard(0).getImage().getWidth(this);
bHit.addActionListener(this);
bStay.addActionListener(this);
bRestart.addActionListener(this);
bHit.setEnabled(false);
bStay.setEnabled(false);
width=getSize().width;
height=getSize().height;
this.add(bHit);
this.add(bStay);
this.add(bRestart);
player_hand=new Hand();//Create the hands
dealer_hand=new Hand();
//make sure that the buttons appear properly
this.validate();
message="";
cards_loaded=true;
System.out.println("End of thread...");
repaint();
import java.io.*;
import java.net.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
public class BlackJackServer extends JFrame{
//Text area for displaying contents
private JTextArea jta=new JTextArea();
public static void main(String[] args){
new BlackJackServer();
public BlackJackServer(){
//Place text area on the frame
setLayout(new BorderLayout());
add(new JScrollPane(jta),BorderLayout.CENTER);
setTitle("BlackJack Server");
setSize(500,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);//It is necessary to show the frame here!
try{
//Create a server socket
ServerSocket serverSocket=new ServerSocket(8000);
jta.append("Server started at "+new Date()+'\n');
//Listen for a connection request
Socket socket=serverSocket.accept();
//Create data input and output streams
DataInputStream inputFromClient=new DataInputStream(socket.getInputStream());
DataOutputStream outputToClient=new DataOutputStream(socket.getOutputStream());
while(true){
//Receive bet from the client
float bet=inputFromClient.readFloat();
//Compute double the bet
float doublebet=bet+bet;
//Send double the bet back to the client
outputToClient.writeFloat(doublebet);
jta.append("Bet received from client: "+bet+'\n');
jta.append("Double the bet found: "+doublebet+'\n');
catch(IOException ex){
System.err.println(ex);
BlackJack bj=new BlackJack();
bj.getSource();
}//end class BlackJackServer
import java.io.*;
import java.net.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BlackJackClient extends JFrame{
//Text field for receiving bet
private JTextField jtf=new JTextField();
//Text area to display contents
private JTextArea jta=new JTextArea();
//IO streams
private DataOutputStream toServer;
private DataInputStream fromServer;
public static void main(String[] args){
new BlackJackClient();
public BlackJackClient(){
//Panel p to hold the label and text field
JPanel p=new JPanel();
p.setLayout(new BorderLayout());
p.add(new JLabel("Enter bet"),BorderLayout.WEST);
p.add(jtf,BorderLayout.CENTER);
jtf.setHorizontalAlignment(JTextField.RIGHT);
setLayout(new BorderLayout());
add(p,BorderLayout.NORTH);
add(new JScrollPane(jta),BorderLayout.CENTER);
jtf.addActionListener(new ButtonListener());//Register listener
setTitle("BlackJack Client");
setSize(500,300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);//It is necessary to show the frame here!
try{
//Create a socket to connect to the server
Socket socket=new Socket("localhost",8000);
//Create an input stream to receive data from the server
fromServer=new DataInputStream(
socket.getInputStream());
//Create an output stream to send data to the server
toServer=new DataOutputStream(socket.getOutputStream());
catch(IOException ex){
jta.append(ex.toString()+'\n');
private class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
try{
//Get the bet from the text field
float bet=Float.parseFloat(jtf.getText().trim());
//Send the bet to the server
toServer.writeFloat(bet);
toServer.flush();
//Get double the bet from the server
float doublebet=fromServer.readFloat();
//Display to the text area
jta.append("Bet is "+bet+"\n");
jta.append("Double the bet received from the server is "+doublebet+'\n');
catch(IOException ex){
System.err.println(ex);
}//end class BlackJackClient
import java.awt.*;
class Card{
Image image;
int value;
/*Constructor*/
public Card(Image image,int value){
this.image=image;
this.value=value;
/*Return the image associated with the card*/
public Image getImage(){
return image;
/*Return the current value of the card*/
public int getValue(){
return value;
/*Change the value of the card*/
public void setValue(int value){
this.value=value;
import java.awt.*;
//import java.applet.*;
import java.net.*;
import java.io.*;
class Deck{
Card[] cards=new Card[52];
int currCard;
public Deck(/*Blackjack myApplet,*/Image[] card_images){
//These are the (initial) values of all the cards
int[] values={11,2,3,4,5,6,7,8,9,10,10,10,10,11,2,3,4,5,6,7,8,9,10,10,10,10,11,2,3,4,5,6,7,8,9,10,10,10,10,11,2,3,4,5,6,7,8,9,10,10,10,10};
//Make all the cards, getting the images individually
for(int i=0;i<52;i++){
cards=new Card(card_images[i],values[i]);
//Shuffle the cards
shuffleCards();
public void shuffleCards(){
Card temp;
//loop through each card in the deck and swap it with some random card
for(int i=0;i<52;i++){
int rand=(int)(Math.random()*52);
temp=cards[51-i];//take the current card
cards[51-i]=cards[rand];//and swap it with some random card
cards[rand]=temp;
//now, reset the currentCard to deal
currCard=0;
public Card dealCard(){
Card card=cards[currCard];
currCard++;
return card;
public Card getCard(int i){
return cards[i];
class Hand{
private Card cards[]=new Card[10];
private int count;
private int value;
public void Hand(){
count=0;
value=0;
public Card[] getCards(){
return cards;
public int getCardCount(){
return count;
public void addCard(Card c){
cards[count]=c;
value+=cards[count].getValue();
if(c.getValue() == 11 && value > 21){//got and ace, so decrement the value of the hand by 10,if it would have been above 21
value-=10;
count++;
public int getValue(){
return value;
public boolean ace(){
int aceIndex=0;
boolean result=false;
for(int i=0;i<count;i++){
if (cards.getValue()==11){
value-=10;
return true;
return false;
Why are you posting this yet again after I told you what the problem was 2 days ago:
http://forum.java.sun.com/thread.jspa?threadID=5147720
Nobody likes to repeat themselves, nor what others have already told you.
Similar Messages
-
Problem with compiling STL using program with Forte C++ 6 update 1 in compat mode
I try to compile SGI STL using program with Forte C++ 6 update 1 and I get an errror
ld -L/opt/SUNWspro/WS6U1/lib -liostream test.o -o test
Undefined first referenced
symbol in file
__0oNIostream_initctv test.o
__0oNIostream_initdtv test.o
Iostream_init - declared as a static class CC4/iostream.h, but nm libiostream.a produce
__1cNIostream_init2T6M_v_
__1cNIostream_init2t6M_v_
and program can't link.
What's wrong?
Thank you for any commentsHi!
I experienced the same problem and the solution looks like the following: in sunpro6.mak file there is a variable STL_INCL that has the following value: -I. -I${PWD}/../stlport
Change that to -I. -I${PWD}/../stlport/SC5 and the problem vanishes. The reason is that stlport/SC5 contains files *.SUNWCCh which are used by SUNpro C++ compiler as standard headers and contain correct STLPort namespace information.
Regars,
Art -
Hello friends , I have started with writing c code on mac using xcode .....but one of my friend told me to use gcc for coding. He started with terminal And used a text editor to compil the c program on his mac.. So please tell me how to do the same and is there any pre stalled text editor on mac if yes then where and if no then which text editor to install and how to install gcc...please help me out thanks in advance !!!
I have started with writing c code on mac using xcode .....but one of my friend told me to use gcc for coding.
Why? If you are developing and writing code on a Mac why would you not use the tools Apple has given you? And Xcode, once you get use to it, is a very nice development environment that will make you life a whole lot easier.
If you insist on using an editor and the terminal I would recommend Emacs but it has a long learning curve so something like TextWrangler will work too.
As for the compiler if you have Xcode installed install the command line tools and you will be able to compile from the terminal.
good luck -
PLEASE HELP!! HOW DO YOU COMPILE THE HELLO PROGRAM?
Hi everybody,
I just install j2sdk1.4.1_01 on my RH 8. And it's install under the directory /usr/j2sdk1.4.1_01 Now, I was compiling the hello program under /home/JAVATEST
and it gives me the following error
Exception in thread "main" java.lang.NoClassDefFoundError: hello
Could anyone please help me on how to solve this problem. I have try to setup CLASSPATH under .bash_profile as this:
JAVA_HOME=/usr/j2sdk1.4.1_01
export JAVA_HOME
CLASSPATH=./:$JAVA_HOME/lib
export CLASSPATH
and still. It would still give me the error. Would anybody please help me on it?? Thanks. I need to do my homework soon. ^<^ thanksI think it's your program.
it's I believe like this isn't it?
// Put this in a file called hello.java
public class hello
public static void main(String args[])
System.out.println("Hello world!");
}Try compiling this with the following command : @home>javac hello.java
then run the command with : @home>java hello
It should run just like that -
Problem in compiling pro * c program
Hi
Greetings ,
I am new to proc, i wrote a small sample program while compiling this program in vc++ 6.0 i am getting the following error
c:\proheaderfiles\database.c(24) : error C2061: syntax error : identifier 'SQL'
c:\proheaderfiles\database.c(24) : error C2059: syntax error : ';'
c:\proheaderfiles\database.c(24) : error C2054: expected '(' to follow 'TYPE'
can anyone help me in this regard
Thanks in advanceFirst compile the proc programe through
windows version proc ,generate the *.cpp file;
Second : add the *.cpp file to visual c++ project
Then compile with visual c++; -
Error when compiling the upload program (Message no. RSAR233)
Hello,
I tried to upload data from a flatfile but I did modified the Comm.Structure, Trans.Structure and Transfer Rules.
After <u><b>activating</b></u> the all changes, I check data from InfoPackage by previewing it. Unfortunately, I got the follow messages from the popup window:
Error 8 when compiling the upload program: row
227, message: Data type /BIC/CCABTWJI_STK01 was
found in a newer
I got this kind of problems many times. I solved it by create a new infosource and everything again. I don't think it's good idea to do this way.
Any better solution would be sincerely appreciated?
-WJ-Another solution:
go out the transaction RSA1 ans return to the transaction RSA1 again.
This would help for me without restarting anything.
Thank you very much for all suggestion.
-WJ- -
Excel extractor produces error "Error 8 when compiling the upload program"
I am trying to test a new Excel extractor I've created but when I do so I get the following error:
RSAR233
Error 8 when compiling the upload program: row 446, message: A newer version of data type /BIC/B0000788000 was
I've tried reactivating transfer structures and transfer rules but with no success. When I activate the transfer structures I can see in the status bar briefly a message refering "Activating Structure /BIC/B0000788000". I am assuming it's the technical name of the structure which supports the extraction.
Any ideas?
Thanks for the help.OK, I can see your point. The Communication structure fields have data types, CHAR, CURR and DATS (those are the data types for the info-objects I am trying to load).
But if I try to assign the same data types to the objects of the transfer structure which match the flat file I get errors like "Invalid data type (DATS) for source systems of type Ext. System.". What I understand this means is that I cannot use data types other than CHAR in the flat file structure so how can I assign data from a CHAR flat file to a DATS destination object? Do I need some kind of conversion? How? Do I really need a routine in the transfer rules? -
Error 8 when compiling the upload program: row 436
Hi all,
pls let me know how to solve this error
Error 8 when compiling the upload program: row 436, message: A newer version of data type /BIC/B0000582000 was
Thanks
PrashantHello SAP gurus.
I know it's a very long time the question was asked, but who cares if it can someday help somebody?
So i just faced the same issue, the solution was sample, i relaunch RSA1 and the problem was solved.
Hope i would be helpful
Salah -
Error 8 when compiling the upload program: row
Error 8 when compiling the upload program: row
248, message: Data type /BIC/CCAWSAI_CID_TEXT was
found in a new
kindly help me out plsHi Raghu,
Error 8 Implies
The last words should be read as "was found in a newer version".
The system says that the active version of your Infosource is older then another version.
I'd recommend to delete Infosource - Source system assignment (with PSA tables etc.).
Then save (activate) the Infosource (communication structure). Then assign source system, create infopackage and load data again.
else..
Goto se38 and Run the program RS_TRANSTRU_ACTIVATE_ALL and relogin..
Plz look the link.
[Error when compiling the upload program (Message no. RSAR233) ]
Hope this helps...
Regards,
NR
Assign points if helpful... -
Problems with downlowding the latest version of iTunes
Resently there have ben problems with downloading the latest versions of iTunes.
And also the version 10.6.1.7 I had to reinstall up to four times, undtil the install
succeeded.
Normally the updates are running without any problems.
I have ben iTunes customer several years, and very satisfied with the program.
Best regards
AageviTry downloading iTunes directly from the Apple website -> http://www.apple.com/itunes/download/
-
Why the sap will compile the abap program again and again?
Every one tell me that when you open some screen at the first time, the sap will compile the abap program and will not compile again at the next time.But I found actually when I open some screen at the 2th or 3th or more times,the sap will still compile the abap again.Such as open the T-CODE va01,mm01,and so on,the sap will show some message below the screen to show it was compiling the abap program.This make the operation spend me huge time.Is there any one could tell me how to resolve the problem or give me some advice?And I will appreciate him/her very much.Thank you.
Hi..
It has very simple answer ... SAP code resides in database and it doesnt deliver a exe or a dll files (obj) to customer ..Now when program initially is loaded it is compiled and its linked object file is stored in SAP memory and therefore it is not compiled next time...
Regards
Anuj Goyal -
Problems with software the update with Nokia 6233
Problems with software the update with Nokia 6233
Hello,
I have so far some-paints tries my software to update.
Each time the update procedure begins, sometime stands then on the telephone “test mode”.
On the computer wars I the reference in the update manager “connection to the telephone broken off” and wants the update to again start.
If I change my profile attitudes since that for example, then after a telephone restart again deleted.
What there can I make?
GreetingsMessage Edited by adisaily on 24-Aug-2007 09:03 AMIt sounds like your 5800 has the earpiece fault that was common with 5800's made before February.
You need to take it to a nokia care point for repair under warranty.
Care points/service centres and repair info:
UK • Europe • Asia-Pacific • USA •
Canada • Middle East and Africa
Elsewhere: Click here, select your country, go to the support section, then select repair. -
I can not do the update , what should I do to fix this error ?
"There was a problem with downloading the file . For tips on troubleshooting , please go to Customer Support . ( Error code : 204 ) ." thanksHi,
Please refer to the help document below:
Error downloading, installing, or updating Creative Cloud applications
Regards,
Sheena -
Problem with running the midlet class (Error with Installation suite )
hi everyone...
i have problem with running the midlet class(BluetoothChatMIDlet.java)
it keep showing me the same kind of error in the output pane of netbeans...
which is:
Installing suite from: http://127.0.0.1:49296/Chat.jad
[WARN] [rms ] javacall_file_open: wopen failed for: C:\Users\user\javame-sdk\3.0\work\0\appdb\delete_notify.dat
i also did some research on this but due to lack of forum that discussing about this,im end up no where..
from my research i also find out that some of the developer make a changes in class properties..
where they check the SIGN DISTRIBUTION...and also change the ALIAS to UNTRUSTED..after that,click the EXPORT KEY INTO JAVA ME SDK,PLATFORM,EMULATOR...
i did that but also didnt work out..
could any1 teach me how to fix it...
thanx in advance... :)actually, i do my FYP on bluetooth chatting...
and there will be more than two emulators running at the same time..
one of my frens said that if u want to run more than one emulator u just simply click on run button..
and it will appear on the screen.. -
Problem with compilation of HelloWorld.java
hi,
getting problem with compilation of HelloWorld.java
CLASSPATH--- C:\java
PATH--- C:\j2sdk1.4.2_04\bin
HelloWorld.java source code in: C:\java
On cmd prompt:
C:\java>javac HelloWorld.java
error: cannot read: HelloWorld.java
1 error
pls help me with this
rgds,
sanlearnsWhat does this command yield?
dir HelloWorld.java
Maybe you are looking for
-
Can't Get Airport Express to Connect to my D-Link DIR-655?
Here's what I did - I should point out all I wanted to do was connect my PC based iTunes upstairs with my stereo system downstairs. First I tried to have the Airport Express join the d-link wireless network. It joined but playback was choppy and I co
-
Error in form submit through netui:anchor tag onClick event
Hello, I am working on a portal application. Below is my jsp code of a simple search screen. The search parameter is customername. <netui:form action="searchCustomer" style="form" tagId="myForm"> <netui:textBox dataSource="{actionForm.customerName}">
-
Can Elgarto TV Diversity stream live TV to Apple TV?
Hi, I know I can save TV to folders and then later stream to Apple TV but can I stream live TV from iMac to Apple TV?
-
Unable to Update to Nokia Belle - E7-00
hii.. I m not able to update my nokia e7 with nokia belle.. Moderator's Note: The subject was amended as we have created a new thread for this topic and moved it to the more appropriate board.
-
C6250 on Win XP will not configure and install
I installed HP Photosmart Full Feature Software and Drivers ver 10.0.1. Doing a network install, the application sees the printer as a network device. However, as it tries to configure and install, I get an ERROR, all it shows me is a large red "X"