How to add java application to html/php website? - java

I never deal with java before. Recently I want to add a game Metal Slug into my website, I got the game source codes from http://www.hackchina.com/en/cont/45242 , but the game is in Java format, is it possible to add the Java game into a html/php website?
Do I need to modify the Java codes? Or I just need to write html to embed the Java game? Mind to show me the example of codes or reference or terms for searching that might help me out?
Is there any place I can download the source codes of Metal Slug game which can embed to website? Haha. I need to modify the game codes because my website allow users to buy the cloth/dress of characters in the game, so I need to change the outfits of the characters in the game...

is it possible to add the Java game into a html/php website?
If it is Java based, it can either be embedded in a web page (applet) or launched from a web page (frame launched with Java Web Start).
Natives (e.g. DLLs) cause a challenge for applets. Either you can launch them free floating with web start, embedded with web start (requires 'next generation' plug-in2 JRE) or otherwise the user needs to run an installer that puts them somewhere that is on the path for Java related natives.

This seems to be a game which needs to be installed on the users drive. You can not embed it in an html file.

Related

How to implement a basic OS style console in java web client?

I'm currently planning on making a simple IRC style chat client and server system using Java for practice. I did some research into different ways of including the client functionality on a webpage like applets and java-web-start. I would like to have the client running on the users machine instead of the server itself. As I interpreted, out of the two, the applet pretty much does exactly that and seems way less effort to set up.
However, it turns out that applets have their own graphical implementation using "Graphics" class to render things like text, lines and shapes. Instead of going for something fancy, I would like to use a simple console interface like cmd on windows or shell on unix systems.
Is it possible to have this type of console running on a webpage as java applet or would I basically have to code the entire graphical look using the tools provided by the Graphics class? For this practice project, it would be ideal just using simple functionality provided in console windows like "nexInt()" and "system.out.print()" instead of having to add complex elements for input and output.
TL;DR:
Is it possible to embed an OS console within a webpage using java and what would be the preferred method of going about it?
Is it possible to embed an OS console within a webpage using java ..
AFAIU it is not possible to embed a console in a Swing or AWT desktop app. As far as embedding that into a web page, that would require an applet. Chrome and FF have completely removed support for applets and IE is set to follow.

Converting Java program to applet

So I have a pretty basic Java app I have been writing in Eclipse.
I now have realized somewhat late that I want this to run as an applet on my website.
How do I setup JApplet? (assuming this is what I need to use)
Is there any "quick fixes" for assuring that the app will be able to be used as an applet?
This should get you started http://www.dreamincode.net/forums/topic/28410-application-to-japplet-and-reverse/
It was the first item in a Google Search, so next time look there first.

Recording/playback audio on web based page with Java

I've found plenty in javascript etc, and for desktop-based ones in Java, but none for web-based java. Any ideas?
For comprehensive access to the Java Sound API, look to the javax.sound.sampled package.
See the Sound Trail of the Java Tutorial for details on how to use the API.
To record sound, the applet would need to be digitally signed (by you) and trusted (by the end user - when prompted at start-up).
Daniel made a good point about sound in web pages. Users generally hate it. Make sure your applet does not attempt to play any sound until requested by the user. Set the volume to a relatively low one.
I believe you can create an applet, which then is embedded into web page. And applets are capable of playing whatever you want, even without authorisation from the user (as far as I remember, it is allowed by JVM sandbox). Applet class even has dedicated method for this: Applet.newAudioClip .

Can Java web applets do the same as offline ones?

I am looking to start a java web applet, as I need something that doesn't need downloaded (saved to computer) and for the most part will work for Windows and OSX.
I have never done anything with java, so my question is can you do everything you can do with a normal java jar file on the web?
More specifically, can you write a web applet that detect window titles (Like the title of an active window), running processes, look in the windows registry, or find hard drive serial numbers?
The applet needs special permissions for these type of actions. It needs to be signed and trusted by the user.
Have you considered using Java Web start? If the communication with the browser from which the applet is run is crucial, then applets are probably the way to go. Otherwise Java Web start is preferred as you'll face less compatibility problems with browsers' Java plugins and different JVM versions.
Yes, but your applets must be trusted by user (user change some browser security settings)

How to start a local port on user's computer (Edited question)

sorry in the past I have not been able to formulate my question coherently. This will be my last try. =|
Basically, I want to do something like this website is doing: http://www.ninjavideo.net/video/56388. They are rendering an iframe that points to a port on localhost. You will see nothing in the iframe if you dont have their applet running (which can be found here: ninjavideo.net/applet.php ). I want to write a script that does something like what applet.php is doing, but I don't think they are using only php code as it won't run on computers that don't have php installed. Do you suppose they are using Java/C to do this?
Thanks for all your suggestions.
An Applet is basically a piece of Java code which is served by a webpage and is supposed to run at the client machine. You can learn more about Applets at Sun's own Applet tutorial. If you're green to Java as well, then I recommend to go through Trials Covering the Basics first. Opening sockets (ports) using Java code is covered here.
That PHP script is just serving the applet code from the server, so that the client can download it.
You could do this in PHP using a ready-to-run Apache setup (there are some that are ready to run from a USB key, should be possible to make into something that a client can install, but is complicated, see e.g. this tutorial) or a product like NuSphere Dock:
PhpDock is a deployment platform for PHP applications.
PhpDock enables you to deploy any PHP web application as a Stand Alone Windows Desktop application w/o any changes in the code.
PhpDock combines NuSphere's powerful embeded Srv webserver and browser components.
I would usually say that if you are looking to build a Windows application, you should go with a tool that is aimed at just that, i.e. C++, C#, Java, the .NET platform, Delphi, and the likes. But if you need some kind of daemon or local web server, you may actually be well off with a product bringing a web server to the desktop.

Categories