浏览器不显示Java小程序 [英] browser doesn't show java applet

查看:574
本文介绍了浏览器不显示Java小程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始用Java小程序,发现这个网站,给出了一个教程。我输入了所有code,但小程序没有在我的浏览器中显示:HelloWorld.java

I'm just starting with java applets and found this website that gives a tutorial. I entered all the code but the applet didn't show up in my browser: HelloWorld.java

import java.applet.*;
import java.awt.*;

public class HelloWorld extends Applet
{
    public void paint (Graphics g)
    {
    g.drawString("Hello World!", 300, 300);
    }
}

这是我的HTML文件

And this is my HTML file

<HTML>
<HEAD>
<TITLE>Hello World Applet</TITLE>
</HEAD>
<BODY>
<H1>Hello World Applet</H1>
<applet code="HelloWorld.class" WIDTH=300 HEIGHT=300></applet>
</BODY>
</HTML>

我已经编译java文件(HelloWorld.class文件),并保存在我的桌面上的所有文件。我使用的Mac OSX山狮的最新版本的Safari。我试图在谷歌Chrome和它说要安装一个插件,我做,但没有更多的事?

I have compiled the java file (HelloWorld.class) and saved all the files on my desktop. I'm using the latest version of safari on mac osx mountain lion. I tried it in google chrome and it said to install a plugin and i did but nothing more happened?

推荐答案

(只是注意:这些事情发生在Windows和Ubuntu的几只是检查下是否有任何以下适用于您的问题),请尝试以下东西:结果
1 - 在HTML文件中,身体标记更改为:

(Just Note: These things take place in windows and a few in Ubuntu. Just check the following if any of the following applies to your problem)Try the following things:
1st- In HTML file, change the body tag to:

<body bgcolor = red>

让你知道你的小应用程序在浏览器中运行,如果你发现你所提到的尺寸的白色矩形,但如预期,因为一些问题,浏览器/ JRE小程序没有运行。

SO that you know your applet is running on the browser if you find a white rectangle of the dimensions you mentioned but the applet is not running as expected because of some problem with the browser/jre.

2日 - 我们使用的浏览器一般都是32位浏览器。做检查,如果你有安装Java的情况下在32位版本的浏览器是32位的。

2nd- Browsers that we use are generally 32 bit browsers. Do check if you have the 32 bit version of java installed in case your browser is a 32 bit-one.

3 - 要检查你的applet是否实际创建,请尝试使用appletviewer中使用的终端上运行的HTML文件

3rd- To check whether your applet is actually created, try running the html file using appletviewer using the terminal.

运行下面的无论是在任何您使用CMD /终端:

run the following either in cmd/terminal whichever you use:

的appletviewer filename.html

appletviewer filename.html

或者如果你使用eclipse / netbeans的,他们通常有一个appletviewer中与IDE集成一起,使他们直接运行的appletviewer。

or if you are using eclipse/netbeans, they usually have a appletViewer integrated along with the IDE so they run the appletviewer directly.

这篇关于浏览器不显示Java小程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆