aspose file tools*
The moose likes Applets and the fly likes Help changing an Application to an Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Help changing an Application to an Applet" Watch "Help changing an Application to an Applet" New topic
Author

Help changing an Application to an Applet

Ashley Perry
Greenhorn

Joined: Jun 21, 2009
Posts: 4
I am new to java and programming. (And new to this forum... hi!) I don't have any programming experience at all. I am taking a course in java, but I am only in chapter three. So I don't know very much yet. Instead of making my dad a card for father's day I wrote a little java program. I can execute it in command prompt or eclipse. He loved it, but he wanted to be able to access it in an internet browser. We learned the difference between a java application and a java applet. I know that java applet must be embedded in html code. That's all the detail the book gives on the topic so far.

Can someone give me an example or explain how to edit the code so that it will be displayed in an internet browser? I tried for several hours to do this on my own. I wouldn't ask for help, but I honestly tried everything I could.

Here's the poorly written program (I am just a beginner ) in case you need to see it:

import java.util.Scanner;

public class James
{

public static void main (String[] args)
{ String name;
int age;
int value;

Scanner scan = new Scanner (System.in);

System.out.print ("What is your name? ");

name = scan.nextLine();

System.out.print ("How old are you? ");
value = scan.nextInt();

System.out.print ("How old is your oldest child? ");

age = scan.nextInt();

System.out.println();
System.out.println();

System.out.println ("Happy Father's Day " + name);

System.out.println ("You have been a father for " + age + " years.");

System.out.println();

System.out.println ("Gee you're old!");

System.out.println();

System.out.println (" You're " + value + " and celebrating your " + age
+ "th Father's Day ");
System.out.println();
System.out.println();

System.out.println ("P.S. Everyone knows Ashley's your favorite.");


}
}
Steffen Schmitt
Greenhorn

Joined: May 08, 2008
Posts: 14
Hi!

I don't think you will get the Application to work the way you tried, as with Applets there is no command line or Shell to read from.

In your case it would be much easier to write a new Applet using TextFields for information input, "send" Buttons to confirm information, and a couple of Labels to display textual output.

With a modern IDE and RAD tool (personally, I prefer NetBeans but you can do the same using Eclipse) you can do this in minutes.

Hope this helps!


Cheers -

Steffen


The man who sets out to carry a cat by its tail learns something that will always be useful and which never will grow dim or doubtful.
-- Mark Twain
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help changing an Application to an Applet