I followed a tutorial for a bit of learning java 2d gaming. It included turning it into an applet.
I use a class which is the launcher class, and it basically just launches it. It can be run as applet (using init) or an application (with main)
I expanded upon the code greatly, Adding a save and load feature using a flat .txt and .png files. which used get_property("user.home") and so forth.
Now I know that applet's on the browser can not save/view the persons computer information. So the above is useless for an applet.
What I have tried doing is commenting and adjusting everything that includes the persons computer information and so forth, And I still can not get the applet to load.
I am using dropbox to host it, I have tried different browsers and made sure the applet was not loaded into my cache for changes I did.
The applet in my eclipse IDE works fine-even saves, so I can't trust it, so I am using dropbox.
My applet did work, this was a long time ago before I developed the engine into my game.
I will share my GameHandler class because it holds the meat of the game. I really should organize this better. Any suggestions?
http://pastebin.com/zdmexGya GameHandler class.
I'm positive saveGame and loadGame do not even get called.
Related
I'm using IntelliJ IDEA, I have coded a frame which I want to put into an HTML file so I can run it in my browser, how do I do this now that I cannot use JApplet? I have found this documentation: http://docs.oracle.com/javase/tutorial/deployment/webstart/deploying.html and this http://docs.oracle.com/javase/tutorial/deployment/webstart/deploying.html but I am new to programming and find this difficult to follow. I don't know for instance how I would go about putting my class files and the image that I used in a separate directory nor do I know how I go about signing my application so that it will run in a browser.
I want to put into an HTML file so I can run it in my browser,
You can use the Desktop class. This class allows you to access default applications from your desktop.
Read the section from the Swing tutorial o How to Integrate With the Desktop class for more information and working examples.
See Java Plugin support deprecated and Moving to a Plugin-Free Web.
Note that is one of my 'copy/paste comments' that does not explicitly mention JFrame based apps., however the links are still relevant in that Oracle & browser makers would not be phasing out support for applets if they wanted programmers to keep trying to shove rich client apps (e.g. Swing GUIs) into thin client web pages.
OTOH you can offer a JFrame (or a JApplet) to be launched from a link in a web page to end up free floating on the desktop of the user by using Java Web Start.
Even then, it is not a simple matter for the programmer or the end user. The programmer needs to ensure the app is digitally signed using a code signing certificate issued by a CA (usually they are expensive). The end user used to just be able to click the link, 'OK' the prompts produced by the Java virtual machine, and see the app appear on-screen. But now most browsers will download the launch file to the local file system rather than directly hand it to the JVM to be launched. So the user faces an extra step in explicitly finding the downloaded launch file and double clicking it.
This is all due to security concerns related to bugs in the plug-ins that run things in web pages. So if you were to find a way around all these hoops, please let us know. It is a security bug that requires urgent fixing.
When developing a Java web-based application, is it necessary to use AWT?
I've been researching this question and the answers are confusing. Take for example, Runescape. The user visits the website and can play the game right there. They can also download a desktop application to play the game with.
If I am developing a game application, and my main window is created in a JFrame but all of my graphics are processed in a JPanel inside the main window, will I be able to implement this inside of a web page without much difficulty in the future? I want my game to be accessible simply by visiting the website and running the application.
Additionally, I've seen people reference "Java Web Start". Will this load the java application inside of the website, or does it install/run Java and execute the program (so if my main function opens a JFrame, it would appear on your taskbar). Perhaps I'm having some confusion between a Java application and a Java applet.
..will I be able to implement this inside of a web page without much difficulty in the future?
No. The security environment around applets was made much stronger in recent times, but even then, browsers tend to put further hurdles between applets and 'onscreen, loaded applets'. Chrome is set to remove the plug-in which would normally embed applets and a few other things.
I want my game to be accessible simply by visiting the website and running the application.
Additionally, I've seen people reference "Java Web Start". ..
Yes, offering a link to a JWS launched JFrame will be a lot easier, and a better experience for the end user.
I am working on a primitive online game client that I wrote as a Java Swing application. My problem is that potential users refuse to download and run any unfamiliar executable. I want my game to be reach as many people as possible and users fear that the executable might contain a virus. That is why I would like to embed the game client into my web page instead. How would you turn this Java executable code (liked below) into an applet?
Thus far I have a main which makes the initial connection to the game server...
https://dl.dropboxusercontent.com/u/214507961/Main.java
A Java Swing GUI that I made with the Netbeans GUI builder...
https://dl.dropboxusercontent.com/u/214507961/GUI.form
Object input/output streams connected to my game/web server...
https://dl.dropboxusercontent.com/u/214507961/Clients_Input.java
https://dl.dropboxusercontent.com/u/214507961/Clients_Output.java
And some buffered images for graphics...
https://dl.dropboxusercontent.com/u/214507961/Image_Repo.java
Note that in future development, I would like to replace much of the primitive looking 2D Swing GUI with content rendered with the Lightweight Java Game Library or some other higher-level video game graphics specific library to make the game look better.
Given that information, what is the best way to make this Java application into an embed-able (applet)? Describe your method and reasoning in such a way that even a college freshman could follow.
Note: Following the advice below, I have tried using WebStart, but I still get an intimidating warning:
Update:
I am in the process of refactoring my code so that the top level container is a JPanel.
I have tried making "GUI" extend JPanel and changing the "gamewindow" from a JFrame into a JPanel.
Modified Main:
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/Main.java
Modified GUI:
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/GUI.java
Despite the changes, Netbeans will not allow this program to run with Java Web Start.
When I enable WebStart and Build/Clean, Netbeans creates two files:
I then clicked Build/Clean and it generated two files:
master-application.jnlp
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/master-application.jnlp
preview-application.html
https://dl.dropboxusercontent.com/u/214507961/Panel_Top_Level_Container/preview-application.html
but no JAR file.
Still working on it. AI moved the remainder of this question to:
Why can't I get Netbeans with Java Web Start enabled to work on my executable?
At this point I'm so tired of putting up with the security hassles and see little to no way to get around certification warnings without paying. I have decided that it would probably be better to just re-write the entire client in HTML5 and javascript.
The basic concept is to build your app (GUI basicly) without using applet specific technologies (like commmunication with web page via JS etc.) and with JPanel as a top level container insteed of of JFrame (Window would be accceptable too, as JApplet extends Window). If you do so, that you will be able to deploy the same code as standalone application and via JNLP as applet.
The digital signature could not be verified by a trusted source.
This is caused by the app. being 'self signed' by a digital certificate we generate ourselves using the SDK tools. Security was increased recently so that 'self signed' apps. get that scary warning. This has been discussed extensively across SO in recent times.
Try looking at the posts under applet+security for details.
Redo the client using HTML5 and Javascript so that you don't run into any prompts or security warnings.
So, I wish to program a game in Java, but be able to post it on online video gaming websites. For some reason, most game websites do not support the use of .jar files, so I sadly cannot just publish that. However, I have seen one method that works, but I need an explanation to what it is, and how to do it. Some Java games appear to be put on an independent website, then an SWF loads the page, like a browser. For example, Runescape on Kongregate seems to run like this, despite the actual game being written in Java.
Is this a known method? Does anyone have any idea on how to do this? Please, I'd really like my game written in Java, not ActionScript. I can't imagine running Java from an SWF similar to how a browser does it is that hard. Thanks.
Runescape uses their own version of Java web start to play the game. When you first play Runescape, Jagex uses Java web start to load Java code to your computer that loads the rest of the game. That's what the update check does every time you play.
You can write your Java application so that it uses Java web start. You have to provide a URL on a web page so that the user's browser can download your code to their computer.
Your other choice is to write a Java applet. An applet is run from a web page. The web page has applet HTML to start the applet.
I am trying to build a small applet that provides some 3d functionality into a website, and i have selected Ardor3D as it seems to tick the boxes. I have just started going with Java, and everything I have learnt so far has been from the examples files which has been enough to this point. The program is distributed by a JNLP file, that downloads the classes and defines how it starts, but I was wondering how to run it as an applet, so the 3d image output would be displayed in its rectangle at its position in a web browser window?
Thank You
Ardor3D has examples of running as an applet. Your game code will be the same as when running as a standalone app, but you extend an applet class instead. See for example the LwjglBoxApplet.