Page 1 of 1

AppletViewer not working

Posted: Wed Jan 14, 2004 3:15 am
by vasastrae
When I try to run appletviewer I get this message:

I/O exception while reading: C:\Documents and Settings\Owner\Desktop\Dots.java (The filename, directory name, or volume label syntax is incorrect)

Does anyone know what the problem is?

also, what is the "Regular expression to match output" suppose to be configured to? This is under 'preferences' and 'tools'.
Thanks for the help!

Posted: Wed Jan 14, 2004 3:23 am
by talleyrand
Without knowing more, and with some very rusty Java knowledge, my gut instinct says that the space in the document path is what's throwing it off.

Posted: Wed Jan 14, 2004 3:45 pm
by vasastrae
well....

i get the error message on every applet that i try to view..


Since it happens on every document that tells me it's something to with textpad and appletviewer not working together. Maybe it has to do with the "Regualar expression to match output" ?
thank you...

Posted: Wed Jan 14, 2004 6:08 pm
by talleyrand
The reg exp part is used to jump the offending line when you have errors in compilation.

Code: Select all

public class HelloWorld extends java.applet.Applet
{
   public void paint(java.awt.Graphics g)
   {
        g.drawString("Hello World!", 50, 25);
        System.out.println("Hello World");
    }
}
This code, saved to c:\bfellows\test space\HelloWorld.java works a-ok when I compile and then hit run applet. Try that as an example to determine whether the issue lies within your code or the interaction of TP and Java.

And just to verify, the setting I have for the run applet tool are
command: appletviewer.exe
Parameters: $BaseName
Initial Folder: $FileDir
Reg Exp: ^.(\([^:]+\)([0-9]+\)

I may have misstyped the reg exp but I suspect a search through the forums would yield the correct one if I have erred.

Posted: Wed Jan 14, 2004 7:40 pm
by MudGuard
according to the JDK documentation, the appletviewer.exe is to be called with the html page containing the applet element.

Do you call it with the java source file?

Posted: Wed Jan 14, 2004 7:49 pm
by talleyrand
For me, it appeared to generate a page for it. Until I had tested it, I didn't think the setup in the tools menu would work but it will try and find an html doc in the current directory to execute against the class file and finding none, it appears to generate its own.

Applet viewer not working

Posted: Thu Jan 15, 2004 1:40 am
by nspils
You might post your applet code so we can see what you're feeding the tool. Are you including the html browser markup within the comment at the top of the file (supply your own x and y values)?

/*
<applet CODE="file.class" width=x height=y>
</applet>
*/

This permits you to run the applet within the applet viewr.

I have received the error message you report with the "standalone" version of appletviewer because I did not include the file extension in the <applet CODE="FILE"> tag.However, TextPad would run it. It was not until I changed to CODE="file.class" within the tag that Sun's freestanding appletviewer would work.

Posted: Thu Jan 15, 2004 2:32 am
by vasastrae
Ok...

well, I tried that standard code and I still get the same error message
then, I tried the suggested preferences and I still get the same message..

(Let me ask you something, when you create HelloWorld.java, do you have to create a HelloWorld.html in the same folder?)

Unless I am making a stupid mistake, it's safe to assume that java and TP aren't interacting?

Appletviewer

Posted: Thu Jan 15, 2004 12:27 pm
by nspils
To use the "Run Java Applet" tool inside of TextPad you do not have to have an HTML page with the <applet></applet> markup. You just need to have the markup within your java code (commented out, which will be skipped over by the compiler but read when the "browser" reads it ...

It sounds to me that your error message is indicating that the appletviewer is executing, but it doesn't know what the applet file is you want to run.

Re: Appletviewer

Posted: Thu Jan 15, 2004 4:09 pm
by talleyrand
nspils wrote:To use the "Run Java Applet" tool inside of TextPad you do not have to have an HTML page with the <applet></applet> markup. You just need to have the markup within your java code (commented out, which will be skipped over by the compiler but read when the "browser" reads it ...
I respectfully disagree on that one. Using java 1.4.1_01, Textpad 4.7.1, I took the aforementioned HelloWorld applet code, used the compile tool in TP, then ran the applet tool via TP. TP generated a uniquely named html file that had enough html in there to call our applet. In the case where there is more than one html file out there, a dialog box pops up asking you which html file you'd like to use or the selection of the the No option will have TP make a new one for a given .class

Vasastrae, I've put a jar (zip) file out here which contains the .java, .class and .html file. Extract the contents to a directory and I would take an iterative approach to resolve this issue.
Step 1 would be to invoke the appletviewer from the command line
i.e. C:\> c:\j2sdk1.4.1_01\bin\appletviewer.exe "\Documents and Settings\Owner\Desktop\HelloWorld.html"

If that works, then try opening the java file in TP and then run the applet tool and see what happens.