Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My first Applet driving me mad.

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hello,

Ok I'm new , I know nothing about Java and I can't work out why I am having so much trouble. So here goes...

I have a simple Applet to beep the PC speaker
Code:
public class beep_pc {
    public static void main(String[] args) {
        System.out.print("\007"); 
        System.out.flush();
    }   
    
}

when compiled and run via DOS prompt everything works fine.

however when I put it in the HTML I don't seem to be able to call the applet to run it, i'm using...
Code:
document.applets("beepPC").beep_pc();
and the JS console errors with object doesn't support this property or method.

Also when the Applet first loads I get a security error regarding the SSL (because it's on https) saying
The site name "WWW" does not match the name on the certificate "www.mydomain.com"
with a yes/no option.

Why is this showing we have a valid SSL certificate and the HTML is as follows
Code:
<applet code="[URL unfurl="true"]https://www.mydomain.com/beep_pc.class"[/URL] width="0" height="0" name="beepPC" mayscript></applet>

I guess i'm doing something stupid, or have really bad code but it seems you cannot beep the PC speaker from JavaScript, so this is my only option.

Hope someone can explain this to me.

Regards,
1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Is the applet actually being loaded?

Maybe you can try

Code:
document.beepPC.beep_pc()
or
Code:
document.applets[0].beep_pc()

Cheers,
Dian
 
Hello Dian,

I've tried both ways, still no joy!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Did you look at Java console? Are there any errors?

Cheers,
Dian
 
I've got the following error load: class
Code:
[URL unfurl="true"]https://www.homeloanpartnership.com/members/scripts/JavaBeep.class[/URL] not found.
java.lang.ClassNotFoundException: https:..www.homeloanpartnership.com.members.scripts.JavaBeep.class

yet if type the URL into the browser you will see it does exist?

so why the error?



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I forgot to add the caused by part of the error msg
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
ok from more googling I found the tag declaration was wrong, it should be...
Code:
<applet code="make_pc_beep.class" codebase="[URL unfurl="true"]https://www.mydomain/"[/URL] width="0" height="0" name="beepPC" mayscript></applet>
Now I don't get any error, nor does JS error, the problem is I don't hear a beep when the JS function is called via a button , that in turn calls the method of the Java class.

So no errors, but also no sound? , so now what?

how do I tell if the class has actually loaded? and why is the method not beeping the PC speaker?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
hello stef,

the beep() method as I understand it doesn't work because it beeps the soundcard not the PC speaker.

I'm needing to beep business machines, which as a rule do not have soundcards or the sound is disabled, hence needing to beep PC speaker not soundcard.

I'm alittle confused re your second comment, why is HTTPS not a good idea, this is a secure encrypted members area, everything is HTTPS, why wouldn't the applet be?

regards

1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
I think what stefan means is that you should try to test your applet first just with http to isolate the error source, and I agree.

Cheers,
Dian
 
well I've put it on non SSL and same thing - no beep, I've definately got the Java VM running and the console open, no dice!

I've tried the toolkit method also non SSL and nothing , I can only get a sound if I run the class via the java.exe as soon as it's embeded into a webpage it stops working.

Don't mean to be defeatest but i give up. I might as well use a simple embeded sound and make that play when I want, on top of which it would load a darn sight quicker than the Java VM does anyway.

Thanks for your input :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top