Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Help changing an Application to an Applet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.");


}
}
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic