Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

How to Create Java Applet or HTML

A topic by Chrand123 created Jun 03, 2020 Views: 1,330 Replies: 8
Viewing posts 1 to 4

Hi,

I am wondering if anyone knows how to create a java applet class. I am using eclipse to make my java project, but when I export it as a runnable jar file and upload it to itch.io, then when I see to check my game it just shows up as a blank screen. On the other hand, when I save my java project as a zip file, when I upload it it says "failed to find index.html". I don't know how to create this file from eclipse.

Does anyone know if it is best to upload the java project as a java applet or html, and how to create either of these?

(+1)

Java applets don't really work in modern browsers. You'll probably have to post it as a downloadable game rather than an embed.

Moderator moved this topic to General Development
Moderator(+1)

What William said. Also it would need to be an applet, derived from a specific class in the Java standard library. Applets don't start from the main method like ordinary Java code.

Thanks for the help. So if I make it as a downloadable file, will people be able to run it without having downloaded Java before? I want to make it so that other people would not have to install/download anything else on the computer, they would just have to open the app and be able to run it.

Moderator(+2)

No, for that you'd have to package it with a Java runtime. There used to be utilities for that. But most computers already have Java installed, or else people know what that means and what to do.

Oh ok, then is it possible to convert the java project to an HTML file. I tried converting it to a zip file and submitting it on itch to be playable on the browser but it said it needs an index.html file. Do you know how to create this file?

Moderator(+1)

With... a text editor?! Look up a HTML tutorial, e.g. on MDN. But you need a web page that embeds a Java applet. Which is 1) not the same thing and 2) not necessary, because Itch supports Java applets directly. Did you look in the list of project kinds when creating a new one?

How did you circle back to making an applet anyway? We were just talking about making it downloadable because most browsers don't support Java applets anymore. And you can't get around that with tricks.

Thank you for taking your time to help me. I was hoping to use itch.io so that people who don't have Java can play my game very easily. I don't want to ask them to download Java so they can run .jar files. I also tried making it an .exe file but I kept getting messages saying that "this program may have a virus" and I do not want anyone to experience that just for trying to play my game. That is why I think that a Java applet is the best thing for me.

So do you know how to take a regular Java program using graphics, and turn that into a Java applet so that it can be uploaded to itch.io? I understand that applets are deprecated because most browsers don't support them anymore, but is there still a way to make them from a Java IDE such as Eclipse?

Moderator(+1)

Once again, you don't have to ask players to download Java because most likely they have it installed already. And to be sure, you can use a utility to bundle the Java runtime with your game. Just search for one online. Spurious warnings from antivirus software are common, many developers run into that problem. And Java applets were deprecated precisely because they were terribly insecure.

No, I don't use Eclipse, but I did make a Java applet long ago, and it has to be made as an applet, which inherits from a specific class in the standard library, and draws on a canvas in the way of output. Eclipse being a big serious Java IDE probably has a project template for that kind of thing. Look for it, and/or check the Eclipse documentation.