NetBeans IDE 5.0 Tutorial for Applets Fang Chu Kamolbhan Olapiriyakul.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

© 2011 Delmar, Cengage Learning Chapter 1 Getting Started with Dreamweaver.
Creating and Editing a Web Page Using Inline Styles
The Web Warrior Guide to Web Design Technologies
© 2010 Delmar, Cengage Learning Chapter 1 Getting Started with Dreamweaver.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
CASE STUDY: Applet Development with GUI and Client-side File Input Arkadiusz Edward Komenda.
Chapter 1 Getting Started With Dreamweaver. Explore the Dreamweaver Workspace The Dreamweaver workspace is where you can find all the tools to create.
The Internet 8th Edition Tutorial 1 Browser Basics.
Applets, HTML and GUI’s Recitation – 04/11/2008 CS 180 Department of Computer Science, Purdue University.
Installing geant4 v9.5 using Windows Daniel Brandt, 06 April 2012 Installing Geant4 v9.5 for Windows A step-by-step guide for Windows XP/Vista/7 using.
Creating and Publishing Your own website
INSTRUCTIONAL SUPPORT SERVICES (ISS) SHORT COURSE, FALL 2012 UMSL Introduction to Web Page Design.
ECE356 – Database Systems Lab 1 – Building a Web Project with NetBeans Tiuley Alguindigue Lab Instructor – University of Waterloo, E & CE Dept. Fall 2013.
CS 160: Software Engineering August 27 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
RIMS II Online Order and Delivery System Tutorial on Downloading and Viewing Multipliers.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 21: Publishing Your Pages on the Web.
Eclipse IDE. 2 IDE Overview An IDE is an Interactive Development Environment Different IDEs meet different needs BlueJ and DrJava are designed as teaching.
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
SEEM4570: XAMPP, Eclipse, Summary of Html Kangfei Zhao Room 711,ERB
Creating a Web Page HTML, FrontPage, Word, Composer.
JSP and Servlets Lecture notes by Theodoros Anagnostopoulos.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. M I C R O S O F T ® Preparing for Electronic Distribution Lesson 14.
Getting Started with Dreamweaver
Renesas Technology America Inc. 1 M16C/Tiny SKP Tutorial 2 Creating A New Project Using HEW4.
Adobe Dreamweaver CS3 Revealed CHAPTER ONE: GETTING STARTED WITH DREAMWEAVER.
The NetBeans IDE CSIS 3701: Advanced Object Oriented Programming.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Web Technologies Website Development Trade & Industrial Education
Introducing Dreamweaver MX 2004
1 Lecture 15 George Koutsogiannakis SUMMER 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
Tutorial 1 Getting Started with Adobe Dreamweaver CS3
XP New Perspectives on Browser and Basics Tutorial 1 1 Browser and Basics Tutorial 1.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
IT 211 Project Integration and Deployment Lab #11.
CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES LECTURE 5_1 George Koutsogiannakis/ Summer
Creating a Web Site to Gather Data and Conduct Research.
Applets Chapter 17.  Java’s big splash onto the scene came in the mid 90’s. The people at Sun Microsystems had managed to work java programs into Web.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 2 Welcome Application Introducing the Visual Basic 2008 Express Edition IDE.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
10/5/2015CS346 PHP1 Module 1 Introduction to PHP.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
Tutorial 1: Browser Basics.
CIS 205—Web Design & Development Dreamweaver Chapter 1.
CPSC 203 Introduction to Computers Lab 23 By Jie Gao.
ECT 250: Survey of E-Commerce Technology FrontPage Publishing pages Unix.
Fall 2005 Using FrontPage to Enhance Blackboard - Darek Sady1 Using FrontPage to Enhance Blackboard 1.Introduction 2.Starting FrontPage 3.Creating Documents.
FTP Server and FTP Commands By Nanda Ganesan, Ph.D. © Nanda Ganesan, All Rights Reserved.
Putting Applets into Web Pages.  Two things are involved in the process of putting applets onto web pages ◦ The.class files of the applet ◦ The html.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
Moodle with Style Integrating new technologies to empower learning and transform leadership.
Liferay Installation Prepared by: Do Xuan Hai 8 August 2011.
Chapter 1 Getting Started With Dreamweaver. Exploring the Dreamweaver Workspace The Dreamweaver workspace is where you can find all the tools to create.
HTML Concepts and Techniques Fifth Edition Chapter 4 Creating Tables in a Web Site.
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
FTP COMMANDS OBJECTIVES. General overview. Introduction to FTP server. Types of FTP users. FTP commands examples. FTP commands in action (example of use).
Creating and Editing a Web Page
Creating and Editing a Web Page Using Inline Styles
Navigating the Course 1. Course Materials 2 Software: Notepad (or TextEdit on a Mac) – comes with operating system Internet Explorer Web Browser FireFox.
Spell Checker web service (you build a web client that interacts with the service) The client uses a servlet class and a JSP page. The user passes information.
CACI Proprietary Information | Date 1 PD² SR13 Client Upgrade Name: Semarria Rosemond Title: Systems Analyst, Lead Date: December 8, 2011.
How to use Drupal Awdhesh Kumar (Team Leader) Presentation Topic.
Getting Started with Dreamweaver
Writing simple Java Web Services using Eclipse
Getting Started with Dreamweaver
Integrating JavaScript and HTML
Getting Started with Dreamweaver
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
Presentation transcript:

NetBeans IDE 5.0 Tutorial for Applets Fang Chu Kamolbhan Olapiriyakul

Deployment Options There are at least three ways to put a NetBeans created applet on the NJIT AFS system. The first method is to create and test source code in NetBeans, but then transfer it to AFS, compile it there, and set it up manually. The second method is to create a JAR file in NetBeans, copy it to AFS, and configure it there with Netbeans. The third method is to package a stand-alone JAR package in NetBeans and deploy it to AFS.

Contents of this presentation The detailed presentation, with code, uses the third option and is discussed last. The other two options are described briefly, along with explanatory material on Applets, AFS, and NetBeans, as an introduction to the final topic.

Setting Up Java Applets on AFS Manually Fang Chu

AFS and Java Applets To create a homepage on AFS for Java Class, see the instructions at Your web pages will have an address like this Use FTP software or AFS Clients to upload your web pages to your directory

AFS and Java Applets To run a Java applet on the web, you embed code similar to the following in an HTML file and then upload the file as a webpage. Applet Container Code Sample: <applet code=“ReadFile.class” width=300 height=350>

Running Java Applets on AFS Log on to AFS (afs1-afs32) Change to your java file directory Compile the java file Make sure that java file, java class file, text file and html applet container are in the same directory Link to the html applet container online to enable the java applet

Log on to AFS Click on “Start” at bottom right Click on “Run” next to bottom

Log on AFS Type in UCID and Pass word

Change Directory Current Directory

Change Directory Change directory to the folder containing “ReadFile.java” Using command “cd”

Compile Java file Compil e java file Using comma nd “javac” No warnin g error info “ReadF ile” generat ed!

Run the Java Applet

NetBeans Essentials for Java Applets Create or import Java applet codes. Debug, compile and run codes. Embed codes into web applications.

Create/ Import Code Step1.Create a new project or open an existing project Step 2. Create a new java applet or open an existing file.

Create a new project Select General>> Application>> Next>>…

Name the new project After naming the project and selecting its directory Click on “finish”

Create a new applet file Right-click on Source-package or new project name>> Right-click on “new”>> Left-click on “Applet”; also name the package where the applet file and text file are saved.

Compile an applet Right-click on the applet file and then left-click on “compile”to compile the java applet

Compiling Message No Error, Can be built and executed

Run the Java applet Include data.txt file in the same folder with java code. “Build the project” by right-clicking on the project name node and then left-clicking it. “Run the file”, similar to “compile”. If applet program is correct, text will be displayed in the applet viewer. Otherwise, it may deliver a message in the bottom without initializing the applet.

Applet Viewer After the project is built and executed, the text will be shown in the applet viewer.

Web Applications Create a web project –Choose File>New Project. Under Categories, select “Web”; under project, select “Web Application”; “next” –Under Project Name, type in a given name and then redirect the directory to the right folder; “finish”.

Deploying JAR files on AFS Fang Chu

Web Application When you want to include an applet JAR file in a web project, you can do so by adding the NetBeans IDE 5.x Java project that contains the JAR file, or by adding the JAR file itself. Note: if you adding the Java project to web project, you enable the IDE to build the applet whenever you build the web application. Therefore, when you modify the applet, the IDE builds a new version of the applet whenever the web project is built. On the other hand, if the applet JAR file is not in a NetBeans IDE 5.0 Java project, the applet source file is not rebuilt when you build the web project.

Web Applications Step1: In the Projects window, right-click the project node and select Properties from the contextual menu. If the applet JAR file is in a NetBeans IDE 5.x Java project, click Packaging, and then click Add Project. Browse to and select the folder that contains the NetBeans IDE 5.x Java project. Note that NetBeans IDE 5.x projects are marked by the NetBeans IDE project icon. If the applet JAR file is not in a NetBeans IDE 5.x project, click Packaging, and then click Add JAR/Folder. Browse to and select the folder that contains the JAR file.

Web Applications To embed the applet in an HTML file, right-click the project node, and choose New > File/Folder from the contextual menu. Under Categories, select Web. Under File Types, select HTML. Click Next. Give your HTML file a name and click Finish. Embed the following tags anywhere between the file’s tags. –FileRead.ReadFile is the full class name –ReadFile.jar is the JAR File that contains applet

Deploying Web Applications Right-click the HTML node in the Projects window and choose Run File from the contextual menu. The server deploys the HTML file in the IDE's default browser.

Success Similar page will be displayed if web applications run successfully.

NetBeans IDE 5.0 Applet Deployment on AFS Kamolbhan Olapiriyakul

Tutorial Outline Creating or importing an applet source file –Creating a java project, create or import an applet source file Running and debugging an applet source file –Run and applet source file, debug it by modifying its parameters in the src folder Embedding an applet in a web application –Create a web project, import NetBeans IDE 5.0 Java project or a JAR file containing applet source files, add applet tags to a JSP file or HTML file, run the web project

Creating the Java project from scratch or from existing sources Java project (file.java) can be created, compile, run and debugged in NetBeans environment A java project can contain the following: –Java package –Java class and interface –Java applet –Html file –And more…

Creating the Java project from scratch or from existing sources On the NetBeans main menu, choose File > New Project. Under categories, select General. Then, click Next. Choose one of the following: –If you are creating a new applet, select Java Class Library under Projects. –If you are importing an applet source, select Java Project with Existing Source and specify the file’s location in the Source Packages Folder

Under Project Name, type project name. Change the project location if you want. Click Finish. If you imported an applet source file, run and debug it. Creating the Java project from scratch or from existing sources

Creating the applet source file Right-click to the project node in the Projects window and select New File/Folder Under Categories, select Java Classes. Under File Types, select Applet. Then click Next. Under Class Name, type file name. Under Package, type Package name. –For example: File name ReadFile Package FileRead

Sample source code: ReadFile Applet The ReadFile program reads a data text file from an applet the URL class is used for accessing web resources In this case, it also provides a method to obtain file access through an InputStream A BufferedReader provides buffering to smooth out the stream flow and to get the readLine () method for grabbing a whole line at once and returning it in a string

Sample source code: ReadFile Applet package FileRead; Import java.applet.*;... public class ReadFile extends java.applet.Applet { StringBuffer buffer; String filename="data.txt"; TextArea td;... }

Sample source code: ReadFile Applet public void init() { td = new TextArea(60, 20); td.setEditable(false); setLayout(new BorderLayout()); add(td, "Center"); //read the file readFile(); }

Sample source code: ReadFile Applet public void readFile(){ String line; URL url = null; try { url = new URL (getCodeBase(), filename); } catch (MalformedURLException e ) { System.out.println("Malformed URL "); stop(); }

Sample source code: ReadFile Applet try { InputStream in = url.openStream(); BufferedReader bufin = new BufferedReader(new InputStreamReader(in)); buffer = new StringBuffer () ; while ((line = bufin.readLine()) != null){ buffer.append(line + "\n"); } in.close(); } catch (IOException e ) {} tdisplay.append(buffer.toString ()); }

Build and run applet source file After the applet source file has been created, you can build and run the applet source file on NetBeans IDE After the project is built and the applet is complied and run, an applet viewer is shown in small window frame If the applet viewer is not successfully loaded, this means that there is an error in your code

Build and run applet source file Right-click the project node and choose Build Project from the contextual menu The ReadFile.jar file is created in the dist folder Right-click the applet class node and choose Run File from the menu

The ReadFile.html launcher file, with the applet embedded, is created in the build folder The applet is launched in the Applet viewer as shown in the left figure Build and run applet source file

Debug the applet source file by modifying its parameters The ReadFile.html launcher file in build folder is overwritten each time when run or debug the applet Therefore, do not modify the launcher file in build folder

Debug the applet source file by modifying its parameters Instead, use the following procedures: –Open the Files window –Copy the ReadFile.html from build folder to the package where the applet class lives in the src folder. Make sure that ReadFile.html launcher file has the same name as the applet class –Edit the ReadFile.html launcher file as needed When the project is built, the ReadFile.html launcher file is copied from the src folder to the build folder

Create the applet-embedded Web Application You can create a Web page that contains HTML source code and Java files by using the NetBeans IDE Java applets can be attached on the HTML source file The HTML page can be view on the default Web browser or the Web browser of your choice –To set up the default Web browser, go to Option on the menu

Create the applet-embedded Web Application –In the General tab, you will see the Web Browser drop-down box in the General section –Choose the Web browser –Note: Java applet works well on Mozilla Firefox, instead of Internet Explorer

Create the applet-embedded Web Application On the NetBeans main menu, choose File > New Project. Under categories, select Web. Under Projects, select Web Application. Then, click Next. Under Project Name, type project name. Change the Project Location to any folder you need. Then click Finish.

Add the applet JAR file to the web project You can either add the NetBeans IDE Java project that contains the JAR files, or add the JAR file itself –Note: if you add the Java project to web project, you enable the IDE to build the applet whenever you build the web application. Therefore, when you modify the applet, the IDE builds a new version of the applet whenever the web project is built. On the other hand, if the applet JAR file is not in a NetBeans IDE 5.0 Java project, the applet source file is not rebuilt when you build the web project.

Add the applet JAR file to the web project In the Projects window, right-click the project node and select Properties from the contextual menu Choose one of the following: –If the applet JAR file is in a NetBeans, click Packaging, and then Add project. Browse to and select the folder that contains java project. –If the applet JAR file is not in a NetBeans, click Packaging, and then click Add JAR/Folder. Browse to and select the folder that contains JAR file.

Add the applet JAR file to the web project Optionally, you can type a location for the applet in the table’s Path in WAR column. By default, the applet JAR file will be copied to build/web folder. Click OK –Note: When you build the project, the applet’s JAR file is packaged in the project’s WAR file in the dist folder and also in build/web folder.

Create and run the JSP file or HTML file Choose one of the following: –Embed the applet in a JSP file, double- click default index.jsp file in the Projects window. This file is created by the IDE. –Embed the applet in a HTML file, right- click the project node, and choose New > File/Folder from the menu. Under Categories, select Web > HTML. Click Next and Finish.

Embed the applet in the file by adding the following applet tag anywhere between the file’s tags: –FileRead.ReadFile is the full class name –ReadFile.jar is the JAR File that contains applet Right-click the JSP or HTML node in the Projects window and choose Run File from the menu Create and run the JSP file or HTML file

Output

Deploy the NetBeans Java Project on AFS Kamolbhan Olapiriyakul

Create the links to Java projects on AFS Create a Webpage for course The course main page should be named as index.html –For example: CS602/index.html Creates the underlying Web pages that link with the course main page –Sample code for the link command is:

Transfer Java project and files to AFS Clients To transfer Java projects to AFS Clients, you need to have File Transfer Protocol (FTP) or AFS Clients software. The FTP and AFS Clients allows you to transfer or exchange files between your computer and AFS servers. –You can download AFS Clients at –See also the installation and setup instruction at –You can also download the Core FTP at

Transfer file to AFS Clients –The path for your AFS personal space should be \afs\cad\u\first_letter_UCID\second_letter_UCID\UCID –For example, the personal space for UCID “ab12” can be found at afs\cad\u\a\b\ab12 Transfer the project folder from your computer to your AFS space. –For example, the ReadFile project are transferred to personal homepage folder on AFS or public_html folder

Transfer file to AFS Clients –Create sub-folder if necessary. For instance, sub-folder CS602 is created to store project files –The path of project, for instance, is

Trouble Shooting Section Fang Chu Kamolbhan Olapiriyakul Also see the separate presentation on “Applet Failures”

Frequently Asked Questions There is an “x” in the applet viewer. Was it initialized?—Both applet structure and code needs to be double checked. The applet runs in NetBeans, but it is not working with AFS.—Check links to see if it is directed to the folder where source and class files are stored. Or transfer codes from NetBeans to server account to compile java file via AFS to see if it is working.

FAQ Applet works with Firefox, but not IE.– IE may require a manifest file with a blank line for a JAR file. See details in the tutorial on JAR files. A Java applet may not work in a browser due to browser configuration, security settings, lack of the Java Runtime Edition, or another incompatibility. Netbeans allows you to specify a browser. Try both and compare the code, especially the deployment descriptor and HTML code.

FAQ Cannot embed applet in the HTML file –Check the code between tag –Different IDE may have slightly different standard of code for applet command Input is accepted in NetBeans but not AFS.– Check the I/O program structure in the code to see if there is a missing request/accept module.

FAQ The following messages have been found: “The applet is not initialized” “Loading Java applet failed” –Try to run applet on NetBeans first – Check the path and syntax of the code

Reference NetBeans quick-start tutorials, open source downloads and FAQ sessions and a particular chapter highlighting applets. java.sun.com/developer/onlineTraining/tools/netbeans_ part1 Quick-start tutorials for NetBeans users and professional developers’ forum where many topics are around applets.

Reference entINetBeans.pdfwww.cs.armstrong.edu/liang/intro5e/Supplem entINetBeans.pdf ndex.htmlhttp:// ndex.html Comprehensive NetBeans introductions with emphasis on Java programming and many samples on Java applets.

Reference Comprehensive Java Applets samples can be found along with detailed documentation, which can be practiced with NetBeans.

Reference NetBeans IDE 5.0 Quick start guide for J2EE Application NetBeans IDE 5.0 Software download. NetBeans tutorial for Applet

Reference NetBeans Web Application tutorial AFS Window Client Software Core FTP Software ReadFile source code ectures/12B/fileReadByApplet.html