Call a Java method from Javascript

M

mhust6

I am trying to call a java method from within my Javascript, but cannot
seem to get it to work. All the examples I have found online and in
the forums are using Java applets. I have a method that I want to call
that does a search, and produces a message dialog displaying the
results. Also, the class file lives next to the html file. How would
I invoke this in my code? This is what I have now:


<script>
function searchStrings(){
Searcher.search();
}
</script>
<form>
<input type="button" value="Search" onclick=searchStrings()>
</form>


I am bad with both HTML and Javascript, so I would appreciate any help
that can be offered.

Thanks!
 
E

Erwin Moller

I am trying to call a java method from within my Javascript, but cannot
seem to get it to work. All the examples I have found online and in
the forums are using Java applets.

Yes. What else?
You cannot call some method in some JVM somewhere else.
If you want JS to communicate with Java, you are talking about Java as an
applet, embedded in a html page.


I have a method that I want to call
that does a search, and produces a message dialog displaying the
results. Also, the class file lives next to the html file.

What does that excactly mean? 'lives next to the html file' ??

I get the feeling you are trying to accomplish something strange.
Please clarify.

Regards,
Erwin Moller
 
H

hust6

You are right in that it was a bit strange. I think I have found a
better and more conventional approach.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top