Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running A Basic Program On The Web

 
Jason Sgalla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jason Sgalla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jason Sgalla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic