This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-10-22 17:56:07

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Putting Java Applets into HTML

How do I put my Java class applet into an HTML document?  I made this test one with

Code:

import java.awt.*;
import javax.swing.*;

public class HelloWorld extends JApplet {
    public void init(Graphics g) {
        super.paint(g);
        g.drawString("Hello World!", 25, 25);
    }
}

It doesn't get any errors from the compiler (in my case, the Terminal app) or the Java console that launches automatically.  The HTML file is

Code:

<html>
<head>
<style type="text/css">
#lbl
{
color:red;
text-align:center;
font-size:1em;
}
</style>
<title>Java Applet Test</title>
</head>
<body>
<applet code="helloworld.class" name="applet" archive="helloworld.jar" width="400" height="100">
Your browser does not support Java
</applet>
<embed src="helloworld.jar width="400" height="100" />
<p id="lbl>It works?</p>
</body>
</html>

Yeah, I know I didn't need the stylesheet.  I just felt like it.  Anyway, I just get a grey box.  The file's' called helloworld.jar if it matters.  And yes, I've got the .jar file, and every file's on my Desktop.

Help, please, and thanks in advance.

Last edited by maxskywalker (2011-10-24 14:09:25)

Offline

 

#2 2011-10-23 10:31:22

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

Wow.  That sunk into page 10 pretty fast.

Offline

 

#3 2011-10-23 10:51:51

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Putting Java Applets into HTML

don't you need to have a .jar not a .class


Posts: 20000 - Show all posts

Offline

 

#4 2011-10-23 11:20:10

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

veggieman001 wrote:

don't you need to have a .jar not a .class

I really have no idea.  How do you make .jar files?

Last edited by maxskywalker (2011-10-23 14:43:35)

Offline

 

#5 2011-10-23 14:43:46

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

maxskywalker wrote:

veggieman001 wrote:

don't you need to have a .jar not a .class

I really have no idea.  How do you make .jar files?

Bump.

Offline

 

#6 2011-10-23 14:56:57

meowmeow55
Scratcher
Registered: 2008-12-24
Posts: 1000+

Re: Putting Java Applets into HTML

Yeah, you need to make a JAR file to run in a web browser. Look at this or Google for it.


Yawn.

Offline

 

#7 2011-10-23 15:26:42

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

meowmeow55 wrote:

Yeah, you need to make a JAR file to run in a web browser. Look at this or Google for it.

Thanks!  Just made my .jar file and I'll revise the HTML now!

Offline

 

#8 2011-10-23 17:35:43

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

Hmm... it says it can't find the file…

Offline

 

#9 2011-10-23 17:50:37

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: Putting Java Applets into HTML

that's weird... :\


Posts: 20000 - Show all posts

Offline

 

#10 2011-10-23 18:18:54

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

Okay, now I redid it (see the original post for changes) to include both the class and jar file (not to mention a Java-not-enabled message), and I don't get the error message.  Just a big gray box (400x100px to be exact) with nothing in it where the applet should be.  That one applet-debugging site (completely useless) was right when it said that it was almost as annoying as a Blue Screen of Death.

Offline

 

#11 2011-10-23 18:25:00

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

Just tried replacing the file names in the HTML file with "Desktop/file_name", just because the VM said that the home directory was my user (didn't know what that meant).  Anyway, I got an error message and switched it back; but we know that my Java VM error handler isn't just broken.

Offline

 

#12 2011-10-24 09:02:54

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

veggieman001 wrote:

that's weird... :\

You said it.

Offline

 

#13 2011-10-24 14:11:16

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

Okay, just changed the <applet> to <embed src="helloworld.jar" /> and it says I need an updated version of Java.  Here's the thing: I use a Mac, and it says that Mac OS X has its own Java player which I update through Software Update, but when I run a software update, it says everything's fine.  I'm downloading it on my Windows now, and will post the results here.

Offline

 

#14 2011-10-24 14:20:41

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

Okay, I just downloaded the latest version of Java (java VM and deployment toolkit), but it still says I'm missing a plug-in.  What else is there?

Offline

 

#15 2011-10-24 16:09:53

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

IS there anything else?

Offline

 

#16 2011-10-24 21:29:16

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

Bump.

Offline

 

#17 2011-10-25 14:38:22

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

Bump … … … … … … … … … … … … … … … …

Offline

 

#18 2011-10-25 14:40:19

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: Putting Java Applets into HTML

I think thats enough bumps....


6418,

Offline

 

#19 2011-10-25 15:31:32

maxskywalker
Scratcher
Registered: 2008-01-27
Posts: 1000+

Re: Putting Java Applets into HTML

CheeseMunchy wrote:

I think thats enough bumps....

Maybe.  But then why isn't it working?

Offline

 

Board footer