开发者

import java class in js

开发者 https://www.devze.com 2023-01-20 06:11 出处:网络
I have a html website and I am using JavaScript. I have a java Class transformation.java with a method convert(a,b) that I would like use in the javascript in my html document.

I have a html website and I am using JavaScript. I have a java Class transformation.java with a method convert(a,b) that I would like use in the javascript in my html document. How can I import the java class in my jav开发者_运维百科a script and use the method convert(a,b)?

Thanks.


Javascript != Java. You cannot import a java class in javascript. The languages are different (despite the names). You need to port the code.

Unless, you want to expose the java code as a servlet and have the javascript invoke it via an AJAX request.


  1. Write your self same logic in java script
  2. Make a server call to your java function using Javascript using DWR


You can't. :) You should check out applets. Java Applets

0

精彩评论

暂无评论...
验证码 换一张
取 消