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

  • SEARCH
  • Home
  • 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 7576653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:58:28+00:00 2026-05-30T16:58:28+00:00

I want Matlab program to call a java file, preferably with an example.

  • 0

I want Matlab program to call a java file, preferably with an example.

  • 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-30T16:58:29+00:00Added an answer on May 30, 2026 at 4:58 pm

    Ok, I’ll try to give a mini-example here. Either use the java functions right from the Matlab window as zellus suggests, or, if need permits, create your own java class. Here’s an example:

    package testMatlabInterface;
    
    public class TestFunction
    {
      private double value;
    
      public TestFunction()
      {
          value = 0;
      }
    
      public double Add(double v)
      {
          value += v;
          return value;
      }
    }
    

    Then turn it into a jar file. Assuming you put the file in a folder called testMatlabInterface, run this command at the command line:

    jar cvf testMatlab.jar testMatlabInterface
    

    Then, in Matlab, navigate to the directory where your testMatlab.jar file is located and run the command, import testMatlabInterface.* to import all the classes in the testMatlabInterface package. Then you may use the class like so:

    >> methodsview testMatlabInterface.TestFunction
    >> me = testMatlabInterface.TestFunction()
    
    me =
    
    testMatlabInterface.TestFunction@7e413c
    
    >> me.Add(10)
    
    ans =
    
        10
    
    >> me.Add(10)
    
    ans =
    
        20
    
    >> me.Add(10)
    
    ans =
    
        30
    

    Let me know if I can be of further assistance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# program which should call Matlab for running a m-file and
I am trying to port a MATLAB program to C++. And I want to
I want to write a really, really, slow program for MATLAB . I'm talking
I am new to MATLAB and I want to write a simple program to
I want to call matlab from QT 4 (used for UI only in my
I'm trying to program an ODE solver (similar to ODE45 in MATLAB). I want
I want to read this file in MATLAB, the file contains these data 1/1/2008
In my matlab program, I want to determine whether a variable or output of
For some MATLAB code that I want to make executable, I need the location
I want to use some Python libraries to replace MATLAB. How could I import

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.