Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6132171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:04:06+00:00 2026-05-23T17:04:06+00:00

i created a java class content method return a String, my question is how

  • 0

i created a java class content method return a String, my question is how to call this function in my javascript code to use the returned value from the java method. I want to call client-side Java code embedded in browser.

here is an exemple of what im talking about:

in my webpage i have a javascript code, here is some of it:

    function createChartControl(htmlDiv1)
{
    // Initialize Gantt data structures
    //project 1
    var parentTask1 = new GanttTaskInfo(1, "Old code review", new Date(2010, 5, 11), 208, 50, "");
......................

i want to create a java class content methods to provide data to this javascript function “GanttTaskInfo”.
for exemple function to get name, get id and date.
well i think this time im clear 😀
i searched a way to call java methods in javascript, and i found applets as you said, but i think its not usefull to me.
thanks again

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:04:06+00:00Added an answer on May 23, 2026 at 5:04 pm

    When it is on server side, use web services – maybe RESTful with JSON.

    • create a web service (for example with Tomcat)
    • call its URL from JavaScript (for example with JQuery or dojo)

    When Java code is in applet you can use JavaScript bridge. The bridge between the Java and JavaScript programming languages, known informally as LiveConnect, is implemented in Java plugin. Formerly Mozilla-specific LiveConnect functionality, such as the ability to call static Java methods, instantiate new Java objects and reference third-party packages from JavaScript, is now available in all browsers.

    Below is example from documentation. Look at methodReturningString.

    Java code:

    public class MethodInvocation extends Applet {
        public void noArgMethod() { ... }
        public void someMethod(String arg) { ... }
        public void someMethod(int arg) { ... }
        public int  methodReturningInt() { return 5; }
        public String methodReturningString() { return "Hello"; }
        public OtherClass methodReturningObject() { return new OtherClass(); }
    }
    
    public class OtherClass {
        public void anotherMethod();
    }
    

    Web page and JavaScript code:

    <applet id="app"
            archive="examples.jar"
            code="MethodInvocation" ...>
    </applet>
    <script language="javascript">
        app.noArgMethod();
        app.someMethod("Hello");
        app.someMethod(5);
        var five = app.methodReturningInt();
        var hello = app.methodReturningString();
        app.methodReturningObject().anotherMethod();
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple Java class as follows: I pass content as a
I've created a Java class that connects to an IIS website requiring NTLM authentication.
Created a Java application to upload documents via CIS (Content Integration Suite) to a
This question is related to my original issue How to return an array from
While you create a user defined class in Java, you do not specify it
In Java, is it possible to create a class definition on the fly while
Is it completely against the Java way to create struct like objects? class SomeData1
At what point would you create your own exception class vs. using java.lang.Exception? (All
I've found a task on some Java programming competition. One must create class Sentence
I created java enterprise application and it consists of ejb module and web application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.