在网页上运行Java应用程序 [英] Running a Java application on a webpage

查看:173
本文介绍了在网页上运行Java应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个我想在网页中运行的Java应用程序。如何做到这一点?

I have written a Java application that I would like to run inside of a web page. How do I do this?

代码如下:

Code is below:

class Permutations {
    static long factorial(int num){
            long factorial = 1;
            for (int forBlockvar = num; forBlockvar > 1; forBlockvar--) {
                    factorial = factorial * forBlockvar;
            }
            return factorial;
    }

    public static void main(String[] args){
            long FactNmR;
            int n = 10;
            int num = n;
            int r = 4;
            int nMr = n - r;
            long FactN = factorial(num);
            if (nMr <= 1){
                    FactNmR = 1;
            }
            else  {
                    num = nMr;
                    FactNmR = factorial(num);
            }
            long permutations = FactN;
            permutations = permutations / FactNmR;
            System.out.println(permutations);
   }
}


推荐答案

有几种方法可以用java做到这一点。

There are several way to do this with java.

一种方法是使用Java Servlet来完成。

One way is to do it with Java Servlet.

您需要一个带有指向Servlet的动作的html表单(一个扩展的Java类)
查看本教程

You need a html form with an action that points to a Servlet (an extended Java Class) Have a look at this tutorial

这篇关于在网页上运行Java应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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