[Solved] Can I call a .java file from a .html file with href or something else without using javascript in-between [closed]


Updated from OP comment:

Thank you very much for your reply and let me correct the question can
I call a function which is written in java directly from a html. –
JAVA Coder Nov 5 at 9:08

Still the same answer. Methods or functions, terminology aside. What you’re proposing is like trying to power a bicycle by attaching an engine piston to it without the engine. Does not compute.

You cannot directly “call” a java process from html/js.

—- END UPDATE

No.

Longer answer:
Java files aren’t called. Java classes are. The Java runtime has to live somewhere for java to be used. Typically that would be in your app server/web server. Its entirely possible to use java to generate the html, but the way your using the term “call” in this case doesn’t make sense. Html doesn’t “call” anything as its really just a rich text implementation (like a painting). Modern browsers implement javascript interpreters (which has nothing to do the Java) to run javascript code.

So, can you write html to “call” java (without javascript): No. Can you use java to generate html: Yes. Can you “call” java from javascript. Only if its are exposed as a web service (e.g. classes in the app server are configured to present http content)

A programming class and web services overview would probably be helpful.

4

solved Can I call a .java file from a .html file with href or something else without using javascript in-between [closed]