steps to display a text file in an applet abhishek mehta

28
Steps to Display a Text file in an Applet Abhishek Mehta

Upload: deirdre-george

Post on 22-Dec-2015

220 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Steps to Display a Text file in an Applet Abhishek Mehta

Steps to Display a Text file in an Applet

Abhishek Mehta

Page 2: Steps to Display a Text file in an Applet Abhishek Mehta

Table of Contents

• Initial Conditions• Source code screenshots• Creating a Jar File• Adding a text file in the Jar file• Uploading the files on Ftp Server• Viewing Applet on the website• Errors and Solutions

Page 3: Steps to Display a Text file in an Applet Abhishek Mehta

Initial Conditions

• Go to the website http://www.eclipse.org and download the latest version of eclipse.

• Extract the downloaded file to a folder and then click the file named “eclipse.exe”– Create a workspace.– Workspace is the area where you create projects /

packages / Interface / Class files. – A folder will be created named “Workspace” in C:\

Documents and Settings\Abhishek Mehta\workspace.

Page 4: Steps to Display a Text file in an Applet Abhishek Mehta

Source Code Screenshot

Page 5: Steps to Display a Text file in an Applet Abhishek Mehta

Source Code (Cont’d)

Page 6: Steps to Display a Text file in an Applet Abhishek Mehta

Source Code (Cont’d)

Page 7: Steps to Display a Text file in an Applet Abhishek Mehta

Creating a Jar file

Page 8: Steps to Display a Text file in an Applet Abhishek Mehta

Creating a Jar file (Cont’d)

Page 9: Steps to Display a Text file in an Applet Abhishek Mehta

Creating a Jar file (Cont’d)

Page 10: Steps to Display a Text file in an Applet Abhishek Mehta

Creating a Jar file (Cont’d)

Page 11: Steps to Display a Text file in an Applet Abhishek Mehta

Creating a Jar file (Cont’d)

Page 12: Steps to Display a Text file in an Applet Abhishek Mehta

Creating a Jar file (Cont’d)

Page 13: Steps to Display a Text file in an Applet Abhishek Mehta

Jar File Created

Page 14: Steps to Display a Text file in an Applet Abhishek Mehta

Screenshot of Data File

Page 15: Steps to Display a Text file in an Applet Abhishek Mehta

Adding a Text File to a Jar File

• Jar files are same as zip files• Open .jar files with winzip or winrar• Add a text file to the archive• Save the file• Next slides will show you the

screenshots

Page 16: Steps to Display a Text file in an Applet Abhishek Mehta

Adding a Text File to a Jar File

Page 17: Steps to Display a Text file in an Applet Abhishek Mehta

Adding a Text file to a Jar file

Page 18: Steps to Display a Text file in an Applet Abhishek Mehta

Adding a Text file to a Jar file

Page 19: Steps to Display a Text file in an Applet Abhishek Mehta

View of Jar file after adding the Text File – “data.txt”

Page 20: Steps to Display a Text file in an Applet Abhishek Mehta

Creating HTML File

• HTML File is required to view the applet on the website

• Name the HTML file with a convenient name

• Save the file, in my case it is on the Desktop

• The next slide will show the contents of the HTML file

Page 21: Steps to Display a Text file in an Applet Abhishek Mehta

HTML File

Page 22: Steps to Display a Text file in an Applet Abhishek Mehta

Uploading the files on FTP Server

• So far we have two files HTML File Jar File (Class file + Text File)

• Upload the Files on any of the Ftp servers from afs1.njit.edu – afs30.njit.edu

• The files should be placed in the “public_html” folder

Page 23: Steps to Display a Text file in an Applet Abhishek Mehta

Screenshot of my FTP space

Page 24: Steps to Display a Text file in an Applet Abhishek Mehta

Applet on Website

• Type the following in the address barhttp://web.njit.edu/~UCID/filename.html

In my case,http://web.njit.edu/~arm36/ReadFile.html

Page 25: Steps to Display a Text file in an Applet Abhishek Mehta

Screenshot of Applet on Website

Page 26: Steps to Display a Text file in an Applet Abhishek Mehta

Applet on Local Computer(using Applet Viewer)

Page 27: Steps to Display a Text file in an Applet Abhishek Mehta

Errors and solution

• One Silly mistake; Did you update the new class file

• If you don’t see the applet on the website Check the java file, the class should be defined

public

OR Check if both the .jar file and the html file are placed

in the same folder

OR Check if you add the data file in the .jar file

Page 28: Steps to Display a Text file in an Applet Abhishek Mehta

References

• Eclipse Tutorial• Java 2 SE API