Forums Register Login

Running A Basic Program On The Web

+Pie Number of slices to send: Send
I have been pretty scattered about the last month or so while I try to get back into learning Java again and have decided to just start from scratch.

I created a blog to keep up with my projects and as a place where people can view my code and comment on changes that should be made to it or just pointers about certain aspects of Java I am having trouble with.

The problem I currently have is that creating an Applet is a bit over my head at the moment and keeping on my track is something I'd like to stick with.

Question:
How can I get my code to run on the blog so that they can simply run the program and see the results? It's a simple console program (Guessing Game). Do I package it into jar file and let them download it? That seems like a hassle for such small code samples.

Any help here would be appreciated.

Also if you want to take a peek at the code and perhaps provide me with some feedback I'd really appreciate that as well.
Blog Link Here
+Pie Number of slices to send: Send
If you want code to run in a browser, and it has to be Java, then an applet is what you have to write. However if you want to write an application which people can download and run, then Java Web Start is also a possibility. But bear in mind that you need the server to be able to support JWS by providing a proper definition for the JNLP MIME type. If you don't control the server then you might not be able to get the admins to do that for you.

Oh... you said it's a console application? I can't even imagine how you could run a console application in a browser. And Web Start presupposes your application is a GUI app too.

Oh... I see it's a Wordpress blog (although you misspelled "wordpress" in the link you posted). They don't even let you put Javascript in your posts. I don't even think you could put an applet into Wordpress, it isn't one of their permitted upload file types.
+Pie Number of slices to send: Send
Thanks for pointing out that type with the URL.

Yeah, for the time being I will only be making simple console based applications just to get into the flow of things.
+Pie Number of slices to send: Send
I'm not sure that Java Web Start will work for console apps... there are security restrictions regarding file access, environment variables etc, which might stop it from starting up a terminal on the remote desktop. Haven't tried though. I think JWS has its own console that you can access by going through the menus, but it might just be for displaying System.out, and not interactive.

Writing an applet isn't hard. Books don't seem to cover them these days because everyone uses Flash instead, but I believe it's just a case of extending the Applet class and then after that it's pretty similar to any other GUI app. (Disclaimer: I have never written an applet.) You'll soon be able to write your own, but in the meantime you can either write your own script to package up the jars, or, easier, use an IDE like NetBeans that automatically produces a distributable jar file every time you compile.
+Pie Number of slices to send: Send
 

Luigi Plinge wrote:I'm not sure that Java Web Start will work for console apps... there are security restrictions regarding file access, environment variables etc, which might stop it from starting up a terminal on the remote desktop. Haven't tried though. I think JWS has its own console that you can access by going through the menus, but it might just be for displaying System.out, and not interactive.

Writing an applet isn't hard. Books don't seem to cover them these days because everyone uses Flash instead, but I believe it's just a case of extending the Applet class and then after that it's pretty similar to any other GUI app. (Disclaimer: I have never written an applet.) You'll soon be able to write your own, but in the meantime you can either write your own script to package up the jars, or, easier, use an IDE like NetBeans that automatically produces a distributable jar file every time you compile.



I used to use NetBeans but switched over to Eclipse a while ago. I will look into it and see if there is something similar with Eclipse.

Thanks
+Pie Number of slices to send: Send
Slight correction to the above: on NetBeans you need to do a Clean and Build rather than just a compile to get the dist folder.

I'm sure you can do the same on Eclipse - I think through File > Export > Java > Runnable Jar File - though I haven't used Eclipse much.
Get off me! Here, read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 847 times.
Similar Threads
Why NullPointerException is defined as RuntimeException?
a user friendly IDE
The Winners Are --
GWT, Maven 2, Eclipse, Spring, Hibernate advice
Knowledge of oracle and Java
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:01:39.