本文介绍了在 GitHub 页面上嵌入 Java Applet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个托管在 GitHub 上的 Java 项目.我想使用 GitHub Pages 在 GitHub 上托管一个嵌入小程序的页面.现在,我正在尝试将小程序嵌入到页面中,小程序文件托管在 GitHub 上的 gh-pages 分支上.我将 Java 小程序导出为已分解",因此所有类文件都显示在其正确的层次结构中.在`index.html,我使用这个代码:

I am working on a Java project that I am hosting on GitHub. I wanted to use GitHub Pages to have a page hosted on GitHub with the applet embedded. Now, I'm trying to embed an applet into the page, with the applet files hosted on GitHub on the gh-pages branch. I exported the Java applet as "exploded", so all of the class files show up in their correct hierarchy. In `index.html, I'm using this code:

<section id="main_content">
            <script>
                var attributes = {codebase: 'cubesorter/me/nrubin29/cubesorter/',
                    code: 'Viewer.class',
                    archive: 'cubesorter.jar',
                    width: '800',
                    height: '600'};
                var parameters = {java_arguments: '-Xmx256m'}; // customize per your needs
                var version = '1.5'; // JDK version
                deployJava.runApplet(attributes, parameters, version);
            </script>
        </section>

但是,我收到了 Viewer.classClassNotFoundException.我的所有设置都正确吗?

However, I get a ClassNotFoundException for Viewer.class. Do I have everything set up correctly?

推荐答案

您需要将 viewer.class 移动到 cubesorter/tree/gh-pages 目录中.简单的修复.不多说了.

You need to move viewer.class into the cubesorter/tree/gh-pages directory.Simple fix. Not much more to it.

 <!-- try the applet tag instead -->
 <applet src="cubesorter.jar" code="https://github.com/nrubin29/cubesorter/blob/gh-pages/cubesorter/me/nrubin29/cubesorter/Viewer.class?raw=true">Java not supported</applet>

 <!-- <section id="main_content">
        <script>
            var attributes = {codebase: 'cubesorter/me/nrubin29/cubesorter/',
                //How is this even parsed?
                code: 'https:\/\/github.com\/nrubin29\/cubesorte\r/blob/gh-pages/\cubesorter\/me\/nrubin29\/cubesorter\/Viewer.class?raw=true',
                archive: 'cubesorter.jar',
                width: '800',
                height: '600'};
            var parameters = {java_arguments: '-Xmx256m'}; // customize per your needs
            var version = '1.5'; // JDK version
            deployJava.runApplet(attributes, parameters, version);
        </script>
 </section> -->

在上面的代码中,我为你热链接了viewer.class

In the code above, I hotlinked viewer.class for you

这篇关于在 GitHub 页面上嵌入 Java Applet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 19:10