Java Program on the Internet -How? Urgent
Hello,
I developed a Mutithread TCPIP socket based Network program "Forex Simulator". It's an applet both from the server side and client side. The Program needs to access the socket as well as Database. The Program is simple. After starting server, many clients can connect and buy and sell currency.
I ran this in my home LAN. Initially, I was having trouble with running applet which rejects socket connection. After searching on the net I modified the Java Run Time Environment java.Policy file and modify permission to connect to my server IP and it works.
I have to upload this program on to internet in a shared server. What should I follow to successfully run this on the net.
There are many java chat program, chart, forex simulator running on the internet. How can I implement my program like that.
Thanking you.
Please please reply me, if someone knows it.
[914 byte] By [
ishraka] at [2007-11-26 18:18:16]

# 1
HI, look.
Applets run locally on the client machines y doesnt matter if you put the applet on a Web server over the internet if a client call the web page with the applet, the applet will be downloaded and executed locally. Thats why modifying the policies may work on your machine only.
Another way to avoid the applet security reestrictions is to sign the applet. Its an easy process you can find on the forums.
So, if your app runs locally on each client, then your dbms must be able to accept those connection from all those users.
Java chats uses sockets to share comunication, a Server to listen the requests, and the server sends the data to all clients.
# 2
RTFM http://java.sun.com/sfaq/#socket
# 4
Hello All,
Thanks for your support. At this moment, I am still in a dark about applet technology. The reasons are:
1. I uploaded my server program and client program on the internet.You can check this out. Both are applet.
http://webpagedesignpro.com/demo/trade/Server1.html
http://webpagedesignpro.com/demo/trade/client1.html
2. When I run my server program from webpagedesignpro.com, server applet loaded and access to my local machine socket. The IP address is 192.168.1.33 and port:2006.
3. Curiously I run the http://webpagedesignpro.com/demo/trade/client1.html from the same machine and I gave IP address 192.168.1.33 and port no 2006. The server accepts the client connection and the program starts running.
But If someone else run the client1.html program from other place (for example if you run the program) how does he know the IP address and port no?
The way I want:
4. How can it be possbile to make the http://webpagedesignpro.com as the originating host and I want to start server which will connect to webpagedesignpro.com port. In the same way, client will be connected to the same host=webpagedesignpro.com and port=2006.
5. Finally, If not possbile the above option, I don't mind, if I start server, it runs in my machine and act as a host. But the point is how do the client will connect to my machine from internet from anywhere in the world.
Thanks for your patient.
Thanking you and look forward to hearing you soon.
# 5
> 2. When I run my server program from
> webpagedesignpro.com, server applet
There is no such thing as a 'server applet'. An applet is something than runs in a browser and is downloaded from a server. So it always executes in the client's PC.
This should explain all the puzzlement you are having.
ejpa at 2007-7-9 5:51:54 >

# 6
1.- Applets are not server side application but, client side, this means that ALWAYS an applet is downloaded to each client machine and if your "server applet" opens sockets, then every client machine will have its sockets opened but not the web server.
2.- Applets have permission restrictions, this means that you cannot use sockets, nor Connect to a database unless you remove those restrictions.
3.- To create a server on your web server you need to run a stand alone app on the server or use something like J2EE
4.- Applets run on web pages but are noy running on the server.
Thats the reasson for applets to take a long time to load the first time.
To remove the securities of applets you have to sign it.
# 7
> The IP address is> 192.168.1.33 and port:2006.That isn't a public address. So if you are trying to connect to that from a client on the internet (for example for a database connection) it will never work.
# 8
Thanks for your comments.
1.- Applets are not server side application but, client side, this means that ALWAYS an applet is downloaded to each client machine and if your "server applet" opens sockets, then every client machine will have its sockets opened but not the web server.
>>Now I understand what applet really does. My server applet opens socket in my local machine. But I don' want that. I want the program to open the socket on server that means in my case http://webpagedesignpro.com and client will connect to the port of that server.
3.- To create a server on your web server you need to run a stand alone app on the server or use something like J2EE
>>I badly need to implement my program on the internet. Is there any tutorials or example anywhere for "How to run standalone program on a web server " or J2ee.Standalone means it's not an applet, am I right?
As ejp mentioned there is no server applet, so how can I make the serverside program running on a server where client can connect to that server.
Finally, What are the steps of or what is the java technology which can run a chat server on the net where people from all over the world can chat to each other. My program is same as a chat server.
Thanks again.
# 9
Which webserver do you use? I mean in your hosting do you have supprt for?PHPJ2EEASPASPXONLY HTML?
# 11
Well, on php I dont know how to do it! try searching how to open a Socket and work eith that on php! I dont know if its posible, or buy a hosting with j2ee support.
# 12
Thank you so much for your instant help.
I have decided to go for J2EE server. Is that free? I want to install J2EE on a dedicated server. Just curiously I am asking If the dedicated server has already my php mysql running, can it be possible to install J2EE at the same time where my Java application will be running.
At last I want to make sure If whether my program will be running on J2EE or not. Because at present my server-side and client are both applet. Should I need to change that to Stand-alone application or not!
Again thanking you.
# 13
> I have decided to go for J2EE server. Is that free?
Overkill. I would go for a Tomcat installation and write a servlet myself, or find a web hoster that will let you run a JVM and just write a straight server application.
> Because at present my
> server-side and client are both applet. Should I need
> to change that to Stand-alone application or not!
There is still no such thing as a server applet, so you have no choice but to reimplement it somehow.
ejpa at 2007-7-9 5:51:55 >

# 14
Well, will you buy a dedicated hosting service or do you have a public IP and you have phisical access to the server!
# 15
> Finally, What are the steps of or what is the java
> technology which can run a chat server on the net
> where people from all over the world can chat to each
> other. My program is same as a chat server.
The first step is to have a public IP - which you do not.
# 16
I have the public IP and I would like to host my program in a dedicated server. That server is already up. http://traderscommunity.com. I would like to install java server there so that my program can run there. Now which server should I install there somebody says J2ee, somebody Tomcat or even IBM websphere. http://traderscommunity.com has already apache-php running and I want the java server side by side.
I have lot of confusion about applet specially confused server applet and client applet. But I realize server applet should a servlet which should be running on the java server and applet will communicate with that servlet.
About servlet I found it can be programmed many ways:using HTTP non-HTTP (socket) and rmi.
As I mentioned earlier my program is a trading simulator (in fact a game), where clients can buy and sell foreign currency. Those data will be stored in the server database.
Can I use HTTP connection to do that? I mean can I avoid socket connection and RMI. Note that my client program is an applet.
Thanks
# 17
Well, listen if you already have your applets (clients one) and the connect to a server you can keep them, what you need to change is the server part.
J2ee is not a software, it is a standar or a especification that defines how to build certain kind of applications using java as parogramming language.
"Tomcat" is a web server like "apache php", but the difference is that tomcat reads jsps and hosts servlets, both runs on the server side.
WebSphere is an application server for j2ee what means (web server+EJB container).
Tomcat is free but I guess you may need a different scope.
If you have a dedicated server and can do whatever you want the I recommend installing a java virtual machine 1.5 o 1.6!
Dont use tomcat nor any J2EE techonology because that is more focused on have dynamic web pages. Make a desktop programms that can handle the connections received if you dont need to manage it remotely via WEB.
The same code of the ("Server applet") you have, you can put it now on the JFrame and thats all.
# 18
I really appreciate your nice and specific reply. I forgot to mention that my server is in the USA while I am in Thailand. So everything I have to do is remote installation. That's why I am unable to do your desktop program suggestion. To access the database and socket connection I need to convert it as a servlet I guess.
Yes, I can do whatever I need in my dedicated server. So you mentioned only to install JVM!! That means it will work as a web server. Then I would like to know where should I put my servlet (server program) so that it can run always.
I think I am very close to understand the technology as this is my first java real life program.
Thank you so much.
# 19
Hi again, well, Anyway you must install things remotely and for installing tomcat you need to install a JVM!
So a JVM is needed in anycase.
Now servlets are java objects than can be called via a browser and can process stuff and send a reply to a web page.
I suggested to do a desktop software because you may lose your PHP feature on port 80 is you replace it with tomcat, I guess that tomcat and PHP can cohexists but I never have done that.
Well, read a bit of what a servlet and a JSP is and what can you do with them and come back and tel me if thats what you need to be able to continue helping!
# 20
Thanks for your reply again. At this moment I really do scare of installing tomcat as it may conflict apache-php.
** Then to run my program what kind of host I need to contact. In another way, what kind of host can run java program normally.
In your reply you wrote: read a bit of what a servlet and a JSP is and [b]what can you do with them[/b]
In my case, isn't that servlet is a must for server side. Becaause, client has to send back information to the server and restored into the database. So, servlet can do this thing. For example, user name verification.
Thanking you.
# 21
> Thanks for your reply again. At this moment I really
> do scare of installing tomcat as it may conflict
> apache-php.
It doesn't. Apache is an HTTP server that runs on port 80. Tomcat is a servlet engine that runs on port 8080 by default. You can change either.
> In my case, isn't that servlet is a must for server side.
Not if you aren't going to use HTTP at the client.
> Becaause, client has to send back information
> to the server and restored into the database. So,
> servlet can do this thing.
That doesn't mean that a servlet is the only solution.
I agree with the posters who say you should just deploy a JVM with your own server inside it. Tomcat is overkill unless you must use URLs and HTTP at the client.
ejpa at 2007-7-9 5:51:56 >

# 22
Tomcat is also form apache and I heard once that php y tomcat can cohexist if you configureit well.
APACHE PHP and TOMCAT are both web servers and both can run on port 80, 8080, 4040, 2020, oe whatever you want, the default for web is 80, but you may install it on another port to keep it for your apps.
What you are saying you need is not a servlet but a EJB, I guess is too complicated at your actual skills, just do a desktop app and try to find a way to manage it remotely.
C ya.
# 23
> Tomcat is also form apache and I heard once that php
> y tomcat can cohexist if you configureit well.
They coexist by default. You don't have to configure it at all.
> APACHE PHP and TOMCAT are both web servers
Tomcat is not a web server. It is a servlet container.
ejpa at 2007-7-9 5:51:56 >

# 24
Thanks for all.
I am sorry ejp saying servlet is a must. I was studying O'really servlet with nonHTTP connection means socket connection where servlet can access to server database as well as communicate with the clients using socket.Then my question is
what should be my server side program which will run on the server and be able to access server database and communicate with the database.
like PHP.
So I will install Tomcat and JRE 1.5 or 6 in my server thinking that it won't affect php-apache at all and Is it possible install both from remote?
Also mention, how to run the servlet (if servlet works) from remote access(SSH) or if Tomcat has web interface like J2EE.