• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Wanting to post simple java games on a web site  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I've learned some basic java and just started making simple GUI games. I was hoping to distribute them by somehow making them playable via my website. However, I'm confused how to proceed as much of my search results are either outdated or intended for more complex java programs.

The solutions most recommended in my research are applets, Java Web Start, or learn javascript.

I've seen suggestions in articles that both applets and JWS are outdated and are questionable for working on most browsers. Plus, do they both require certification to be able to run online? I'm not prepared to pay certification fees to share some elementary homemade games online.

Or I've heard...learn javascript which sounds like a completely different language. I'm hoping I can find a solution that utilizes all the java I just learned.

What other options am I missing that could work simply and not make a mountain out of a molehill?

Thank you. core
 
Saloon Keeper
Posts: 9239
177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

It depends. Do you want them to be able to play your game within their browser? If not, then your users can just download an installer file from your site and play the game in a desktop client written in Java. If you want them to be able to play it within their browser, it depends on whether the GUI must update dynamically, or whether you can just redirect the browser or refresh the page after the user has interacted with the game. If the GUI needs to update dynamically, your best choice really is to learn some JavaScript. Most of your game can still be written in Java, but you need at least some JavaScript to trigger dynamic updates in the GUI.
 
Corey Saines
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears that having the user download the jar is the simplest and more straight-forward option. What is the installer file? is that something that runs a jar or would that be me packaging the jar into something else that runs stand-alone for the user? Is the installer a link to oracle's JRE package or something I'd need to build for the end-user?
 
Stephan van Hulst
Saloon Keeper
Posts: 9239
177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An installer is simply an executable that puts the application and its dependencies in a location of the user's choosing, and possibly configures the application before its first use.

If your application consists of only one executable JAR file, you don't need an installer if you require that the user has a JVM pre-installed. It's possible to create installers that download a JVM and install it so it's shared between applications, or as part of your self-contained application.

It all depends on how easy you want it to be for your users to be to start your game the first time.
 
Corey Saines
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks stefan. I'll look into installer packages. I do want want this to be as easy as possible for the end user.
 
Stephan van Hulst
Saloon Keeper
Posts: 9239
177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a few tools that build installers for Java, but from the top of my head I don't know of free ones. I used to use install4j and was really happy with it, but I had a paid licence.
 
Corey Saines
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A search for "Multi-Platform Java Installer Builder" yielded a swarm of promising looking results, including the open-source IzPack.

Thanks for pushing me into the right direction!
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Corey Saines wrote:I do want want this to be as easy as possible for the end user.



Hi, Corey. I stumbled on your post and so I registered to tell you the following:

It sounds like you should be wanting to make your games playable in a browser with HTML5. To do so, you can write in Java then auto convert everything to Javascript.

I really dislike recommending anything from google, but still I have to say that Android Studio might be ideal for you. You write in Java, test as a desktop jar but then can make it all work on the web for users without any JRE or Java, just Javascript. (It uses GWT.)

A downside is that you have to learn the IDE, which btw is based on IntelliJ IDEA. An upside is that you get to learn the AS/IDEA IDE, which to me is fun in itself. It's really great.

Another upside is that you can easily use the libGDX game library - which is very good in itself and is rather well documented, too. You can also easily make a version for phones, if you want to try that just for kicks.

Anyway, this seems like a good site with lots of nice people, so I dropped in to post this. I can tell you how/where to get started (after installing), if you're interested.
 
Stephan van Hulst
Saloon Keeper
Posts: 9239
177
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch Jerry!
 
Corey Saines
Greenhorn
Posts: 11
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jerry,

Thank you very much for taking the effort to get me that reply. My research has been screaming at me that HTML5 is the most reliable cross platform way to go (sounds like applets and Java web start are being phased out and not reliably supported). I don't think you could've given me a more ideal suggestion.

Ironically, I don't care much for the google technologies that my job forces on me as well....
 
Stephan van Hulst
Saloon Keeper
Posts: 9239
177
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I don't want to suggest that GWT is inappropriate to use in your case, I do want to say that I personally find it terrible to work with and that the code it generates is horrific. If you want to create a dynamic web page I really recommend learning a different language that transpiles to JavaScript, such as ES6 or TypeScript.
 
Jerry Corker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Stephan. My experience with the GWT HTML5 version was with a simple game. I'll keep in mind your warning that things might break down with something more complex. Still, I was amazed that the HTML5 version of the simple game was exactly the same as the desktop jar version. Very smooth. What could you suggest as a way to kind of stress test it? More and more actors? Using more memory?

Corey, I usually like to poke around on my own before going through tutorials, but with the AS/GDX that was a time-wasting mistake for me. It's best IMO to start with the tutorial called "a simple game", probably it's on Github. Then the bottom of that page links to an extended version of the same game. You can skip all the Android parts, since that will just sidetrack you extensively for now.

Keep in mind for down the road that there are some things in GDX that look non-Java-ish. But they're done that way in order to minimize GC as much as possible, which might cause stuttering delays on phones. Another GC-saving example is that the Iterator is reusable (unlike the builtin java one, AFAIK), so that there isn't an Iterator object to garbage collect after every screen draw.

 
Corey Saines
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gotcha. I am in Android Studio and nothing is intuitive to me, so I'm off to the simple game tutorial.

Noted, Stefan. This is mostly for my students' simple text-based and simple GUI games (I teach AP Computer Science in a high school), so I'm hoping that Jerry's success extends to my students' projects. If not, I'll keep that IzPack installer packaging nearby...
 
Corey Saines
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jerry,

how do you export html5 from Android Studio, so that I can stick that code into a webpage? I only see Android device options inside the studio.
 
Jerry Corker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Corey, did you have Html checked when you used gdx-setup.jar to create the project that you imported into AS? Also have desktop checked.

Then near the center top on AS, there should be a dropdown that lets you select which you are targeting. You test by running Desktop because that's so fast, just a click. When you later build the HTML, you have to go into the HTML directory to manually copy the files.
 
Jerry Corker
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Btw, it's a real bear to change package names. So once you'll be working on a real project, it's best to have all those ducks in order when you initially create the real project with gdx-setup.jar.
 
Corey Saines
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so I download:

Download LibGDX Project setup tool "gdx-setup.jar"

and use that in conjunction with Android Studio, or is that jar part of Android Studio?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!