Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Running A Basic Program On The Web Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Running A Basic Program On The Web" Watch "Running A Basic Program On The Web" New topic
Author

Running A Basic Program On The Web

Jason Sgalla
Greenhorn

Joined: Mar 22, 2010
Posts: 10
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Mar 22, 2010
Posts: 10
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

Joined: Jan 06, 2011
Posts: 441

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

Joined: Mar 22, 2010
Posts: 10
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

Joined: Jan 06, 2011
Posts: 441

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running A Basic Program On The Web
 
Similar Threads
Topic for SCJP JavaRanch Journal Article
Error Message Exception thread "main" Java.lang.NoClassdef Found Error Hello...?
Java, Send URL, Get URL
OSGi Myths
Long term review