Google Answers Logo
View Question
 
Q: Java applett question ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: Java applett question
Category: Computers > Programming
Asked by: purplepit-ga
List Price: $15.00
Posted: 07 May 2003 02:26 PDT
Expires: 06 Jun 2003 02:26 PDT
Question ID: 200529
How can I test some Java applet code using the standard internet
explorer or netscape?

Request for Question Clarification by seizer-ga on 07 May 2003 02:32 PDT
Hello again purplepit!

I'm not sure I understand exactly what you wish to do. Are you hoping
to load a Java applet using a web browser (like Internet Explorer or
Netscape)? Or do you need to do more than that?

Thanks,

--seizer

Clarification of Question by purplepit-ga on 07 May 2003 08:03 PDT
Not Exactly!!
It just wondered if there was some kind of validator on the web where
I can check to see if the code works!!!!
Thanks

Request for Question Clarification by answerguru-ga on 07 May 2003 08:36 PDT
Hi again purplepit-ga,

Are you familiar with how to run your applet yourself? If not, I can
show you how to do this. However, validating your applet is a bit of a
grey area – since you are running already compiled code you can be
somewhat confident that your code is syntactically correct. Since
other web languages like HTML and XML do not need to be compiled, a
validation process makes sense.

If you are trying to determine whether the applet does what you want,
you are unlikely to find a validator for that purpose since only you
know what you really want!

Cheers,
Answerguru-ga

Clarification of Question by purplepit-ga on 08 May 2003 11:48 PDT
Hi there,
I thought I knew how to run and compile this but it doesn't seem to be working.
can you help!!!!!
Answer  
Subject: Re: Java applett question
Answered By: answerguru-ga on 08 May 2003 13:25 PDT
Rated:5 out of 5 stars
 
Hi purplepit-ga,

I will provide this answer of how to compile and run a Java applet in
terms of the applet that I previously created for you:

COMPILING:

1. First of all, bring the code that was provided into a file called
"But2.java". This is important because the name of the file (excluding
the .java) must be the same as the class being defined in the file.
2. Now we need to compile the file from the command line as follows:
> javac But2.java
3. This will produce a compiled file called "But2.class"

CREATING HTML WRAPPER

Since an applet is designed to be displayed in a browser, we need to
create an HTML file where we reference our compiled applet. It is
important to understand that browsers are not capable of loading
.class files unless they are embedded in an html file. The code for
this file is as follows:

----------Begin HTML Code---------------

<html>
<head>
<title>Welcome to the Button Applet</title>
</head>

<APPLET  CODE = "But2.class" WIDTH = 500 HEIGHT = 500 >
</APPLET>

</html>


----------End HTML Code---------------

You can take the code above and save it in an HTML file (I named mine
But2.html just to be consistent). The most critical part of this file
is the APPLET tag, which references your compiled applet and also
defines the dimensions of the applet with the HTML page.

You should now have your But2.class and But2.html files stored in the
same folder.

RUNNING YOUR APPLET

At this point your applet can be run from a normal browser (such as
Internet Explorer or Netscape) by just opening the html file in the
browser, but I like to use the browser built into the Java Runtime
Environment – you can invoke it from the command line as follows:

> appletviewer But2.html

This will bring up your applet the same way it would in any other
browser, but ensures that all necessary Java components are installed.

That’s all there is to it – if you have any problems following these
instructions do post a clarification and I will get back to you
promptly.

Cheers!

Answerguru-ga
purplepit-ga rated this answer:5 out of 5 stars and gave an additional tip of: $10.00
Great Answer!! and very helpful.....Thanks

Comments  
Subject: Re: Java applett question
From: answerguru-ga on 08 May 2003 14:17 PDT
 
Thanks for the kind words and generous tip purplepit!

answerguru-ga

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy