How to get started on java applet client/server game?
Hi,
I've googled, but didn't find any useful information about creating java applet client/server game. I've followed the example of Client/Server Tic-Tac-Toe Using a Multithreaded Server in Java How to Program from Deitel, but I when I tried on Applet, my cliet doesn't communicate with the server at all. Any help to get started with Applet would be great. Thanks!
well, i decided to put in portion of my codes to see if anyone can help me out. the problem I have here is the function excute() never gets called. here is my coding, see if you can help. Notice, I'm running this on Applet thru html page. This shouldn't be much different than running JFrame in term of coding right?
Server.java
public void init()
runGame = Executors.newFixedThreadPool(2);
gameLock = new ReentrantLock();
otherPlayerConnected = gameLock.newCondition();
otherPlayerTurn = gameLock.newCondition();
players = new Player[2];
currentPlayer = Player1;
try
server = new ServerSocket(12345, 2);
catch (IOException ie)
stop();
message = "Server awaiting connections";
public void execute()
JOptionPane.showMessageDialog(null, "I'm about to execute!", "Testing", JOptionPane.PLAIN_MESSAGE);
for(int i = 0; i < players.length; i++)
try
players[i] = new Player(server.accept(), i);
runGame.execute(players);
catch (IOException ie)
stop();
gameLock.lock();
try
players[Player1].setSuspended(false);
otherPlayerConnected.signal();
finally
gameLock.unlock();
Client.java
public void init()
startClient();
public void startClient()
try
connection = new Socket(InetAddress.getByName(TienLenHost), 12345);
input = new Scanner(connection.getInputStream());
output = new Formatter(connection.getOutputStream());
catch (IOException ie)
stop();
ExecutorService worker = Executors.newFixedThreadPool(1);
worker.execute(this);
}So after worker.execute(this), it should go to Server.java and run the function execute() right? But in my case, it doesn't. If you know how to fix this, please let me know. Thanks!
Similar Messages
-
How to get rid of "Java Applet Window" from JDialog
Hi Friends,
I am developing an applet that uses JDialog class. I want to get rid of "Java Applet Window" that appears at the bottom of my JDialog.
When I run my application from the web, I do not want that to show up.
Is there any way of doing it ?
Many thanks in advance.
Rameshhttp://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%22Java+Applet+Window%22&col=javaforums&x=36&y=9
-
[Ask] Getting Started to Java Card 2.2.2 or 3.0
Hi Friends..
I'm currently tasked to create Java Card application that would be loaded to MIFARE / DESFIRE Card..
How to solve it?..
I have Omnikey Cardman 5321 SmartCard Reader, and i have MIFARE and DESFIRE Card.
I've tried to created simple Java Card application (Java Card 3.0)..
Actually, i prefer Java Card 3.0 because its based on Servlet.. (i'm more familiar with Servlet than Applet :) )
Could i load that application onto MIFARE / DESFIRE Card?..
Is there any Card that have supported for Java Card 3.0?..
or do i've to use Java Card 2.2.2?..
How to getting started with Java Card 2.2.2?..
is there any books that described about it?..
Thanks in advanced..hanks safarmer for your reply..
yes, i've compiled and run that code in Netbeans 6.9m1, but i got this message error :
Exception in thread "main" javax.smartcardio.CardException: connect() failed
at sun.security.smartcardio.TerminalImpl.connect(TerminalImpl.java:67)
at javaapplication1.Main.main(Main.java:32)
Caused by: sun.security.smartcardio.PCSCException: SCARD_W_UNRESPONSIVE_CARD
at sun.security.smartcardio.PCSC.SCardConnect(Native Method)
at sun.security.smartcardio.CardImpl.<init>(CardImpl.java:65)
at sun.security.smartcardio.TerminalImpl.connect(TerminalImpl.java:61)
... 1 more
Java Result: 1The card's status is SCARD_W_UNRESPONSIVE_CARD.
How to solve this? How to make the SmartCard become a "RESPONSIVE CARD"?..
Please help me regarding this..
Thanks in advance.. -
Starting a Java applet???
I want to start a Java applet with this one JAR file I have. What is the code I need to put into the HTML to initiate the applet. I have this so far, but I don't know the class required:
<applet code = "whatclassdoineedhere.class"
archive = "file.jar"
width=256 height=256>
</applet>
I am wondering what class I need to get it running. I'm completely new to Java, and am just experimenting with some things.Let me know if it doesn't work, by the way, I suggest you to use the Object Tag like this, it makes the user behind the internet terminal, know if it has the Java Plug-in; if not, it tries to install it, like when using flash.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>MyAppletSigned</TITLE>
</HEAD>
<BODY topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0' BGCOLOR='black'>
<OBJECT classid='clsid:8AD9C840-044E-11D1-B3E9-00805F499D93'
codebase='http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0'
width='100%'
height='95%'>
<PARAM name='code' value='MyApplet.class'>
<PARAM name='codebase' value=''>
<PARAM name='archive' value='MyJar.jar'>
<PARAM name='type' value='application/x-java-applet;version=1.4'>
<PARAM name='scriptable' value='false'>
<COMMENT>
<EMBED type='application/x-java-applet;jpi-version=1.4'
width='100%'
height='95%'
code='MyApplet.class'
codebase=''
archive='MyJar.jar'
scriptable='false'
pluginspage='http://java.sun.com/j2se/1.4/index.html'>
<NOEMBED>
</NOEMBED>
</EMBED>
</COMMENT>
<P>
You don't have Java 2 SDK, Standard Edition v 1.4
</OBJECT>
</BODY>
</HTML> -
Starting an Java-Applet with https
Is it possible to start a java-applet
from a secure web-page?
https://..../applet.html
If yes - HOW?
nullMy code looks something like this
StringBuffer queryString = new StringBuffer(Applet.getCodeBase().toString());
// append all the variables I need here
URL dataUrl = new URL(queryString.toString());
BufferedReader br = new BufferedReader(new InputStreamReader(dataUrl.openStream()));This works from both http and https The protocol is the same as the how the page itself was loaded. -
How to get start to develop Oracle database applications with NetBeans?
Dear Ladies and gentlemen,
I am new to NetBeans. And I know nothing about Oracle. I have installed the
NetBeans 6.8, and I want to learn Oracle database application development
with NetBeans. I don't know how to get start. Give me some suggestions,
please. Thank you very much.
Best Regards
Ma XiaoguangDownload Oracle Express Edition for educational purposes and start from there.
Download at:
http://www.oracle.com/technetwork/database/express-edition/downloads/index.html
Documentation at:
http://www.oracle.com/pls/xe102/homepage -
How to get database connection in applet
Hi,
I am trying to prepare database connection in applet. After preparing connection with database it'll read same values from table.
At the time of development it works fine. I have used esclipse IDE for coding and testing.
But when I try to call that applet from browser. It is giving ClassNotFound exception.
Does anybody know How to get database connection in applet ?
Please help me if anybody know solution for this.
Thanks,
RajeshAs per my knowledge is conserned
1 u can get the database connection in a jsp page and u send the result set as param to the applet and u can use retrieved values as if they were of the same applet if u r interested i can send the db connetion coding for jsp my id [email protected] -
Adobe Illustrator Help: tips for how to get started?
I am new to adobe products. Does anyone have any tips for someone new who is just starting out
with adobe illustrator? I have not used it before. Any beginner tips on how to get started with adobe
illustrator would be appreciated. Thanksstart by reading the documentation and follow the samples shown, get familiar with the user interface, get to know where the tools are and what they do...and the most important thing practice, practice, practice.
other than that, there are plenty of resources online, depending on your learning style, buy a book, follow tutorials, watch videos, take a class. -
How to get the IP of the client when TCP connect in the server
How to get the IP of the client when TCP connect in the server.
The only parameter got from the connection is connectionID.
Solved!
Go to Solution.I guess you're using "TCP Wait on Listener" on the server. This returns the remote address and port (as optional outputs).
-
Cloud and Pro features of Behance, how to get started?
Hi,
I want to find out more about http://www.adobe.com/products/creativecloud/behance-community.html
How do I actually set this up, I can't find how to get started. I currently have a Muse website on BC.
~ AnitaAnita1390,
You will get Behance integration with the new CC which is not yet launched. This article will give you an idea about the steps you need to follow to get stated with Behance.
http://helpx.adobe.com/creative-cloud/kb/publish-behance.html -
How to get started on Developer Server
Hi
Could you show me how to get started with developer server 6? How can I deploy an existing form to the web? Where can I read more information on this topic? Thank you.hi,
It is avialble in the below URL:
http://technet.oracle.com/docs/products/developer/doc_index.htm
read it and try it
null -
How to get the absolute path of logicalhost server domain on Windows?
My logicalhost server domain behaves strangely. I am reading a file from collaboration definiton, that is located in the logicalhost/is/domains/domain1/config folder. I thought, that this folder is used as an application root folder so I can read files like ./file from there. And it worked.
But then I've installed the domain as a Windows service, restarted the PC. When the domain1 gets started, I get exceptions saying that the file can't be found. Then I restart the domain (in domainmgr.bat) and it works again.
I am pretty sure that using the absolute path will solve this issue, so my first question is: How to get the absolute path of logicalhost server domain on Windows?
And my second question is: Why does this happen?The default folder for a Windows Service is the system32 folder contrary to the instance root folder when starting it as a normal process.
That's the why, haven't tried the how, but you should be able to get the value by calling System.getProperty("com.sun.aas.instanceRoot").
Hope this helps
Paul -
How to get the Change node in Production Server!!!!!
Hi Guys,
Kindly let me know how to get the Change node in Production Server for the Transaction Code Pe03 for generating the Acknowledgement No for the year 2008 .
Plz provide me the steps how to get the Change Node for Acknowledgement No so tat i can get the configuration done.
Regards
Ansuman Mohanty.Hi Mr!
If you want to generate the e-file feature 40ACK, do it in our Customization client box (Golden box) & save the request & move to Quality & production.
Still if you need to workout only in Production, than with the help of Basis people you can get the Production change mode for 5 to 10 min time & can generate it. But mostly Basis people wont give us change mode for Production box ... with ur request they can do..try it.
Did u collected 4 quarter TAN no's for 2008 Quarter...if not collect it & generate it at a time.
All the best:-)
Kind Regards,
Saisree.S -
How to get the absolute path of logicalhost server domain on Windows Sun
i am reading a file from Xsql Folder, that is located in the logicalhost Sun\AppServer\domains\domain1\applications\j2ee-apps.(IN Sun Application Server)
I am pretty sure that using the absolute path will solve this issue, so my first question is: How to get the absolute path of logicalhost server domain on Windows?
i tried with System.getProperty("com.sun.aas.instanceRoot").
but i am able to retrive Sun\AppServer\domains\domain1 upto this .i am unable to retrive Sun\AppServer\domains\domain1\applications\j2ee-apps.
please suggest me how u can get absolute path in sun application serverTake a look here
-
How to call procedure in Java from SQL Server Database
Hello Every Body
i Have Question about
How to call procedure in Java from SQL Server Database
ThanksHi,
have you tried a Google search? I just gave it a 3 second try and already found: http://stackoverflow.com/questions/6113674/how-do-i-execute-a-ms-sql-server-stored-procedure-in-java-jsp-returning-table-d
Frank
Maybe you are looking for
-
Error while transporting the transfermactions
hi, i am transporting transformations dev to qty. while transporting i am getting error msg: 1) No Rules exists. Transformation : Rules 1 could not be imported. Transformation : Rules 2 could not be imported. Transformation : Rules 3 could not b
-
After upgrading to Mavericks, Dock randomly moves to secondary screen
I've seen a few quirky things since upgrading to Mavericks, (backup taking forever, updates I know to be available not showing, etc.) but this is the strangest. I have a MacBook Pro mid 2012, 15", non-retina with an externally connected (Thunderbolt
-
4.1.2 Update not recognizing headphones
I upgraded to 4.1.2 and now the phone is not recognizing when headphones are plugged in. I'm tried several headphones that all work on other devices. I've also ensured that there is no lint in the headphone jack.
-
I downloaded firefox 4.0 and attempted to use business objects. A screen comes up saying that a plugin is required but when I click on the screen, it say's no plugin is found. I am using the latest version of Java but it seems that the plugin is not
-
Moving songs and such to a new PC
My old PC failed. I pulled the hard drive and connected it to the new PC with a USB cable. I copied the contents of My Music folder to the new PC. iTunes sees the song titles and album art but when i try to play a song I get an error message - "The s