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 9192559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:57:12+00:00 2026-06-17T20:57:12+00:00

I have a very complex application that uses CUDA and was write in C.

  • 0

I have a very complex application that uses CUDA and was write in C. This application is command-line only and now I want to build a GUI using Java Swing.

I don’t want to rewrite C code, so I’m calling the command-line version using a ProcessBuilder object. This way I can read messages from it and show on a console inside the GUI.

This is the code I’m using:

String command = "myApp";
pb = new ProcessBuilder("bash", "-c",command);
pb.redirectErrorStream(true);
Process shell;
try {
        shell = pb.start();
        InputStream shellIn = shell.getInputStream();
        Drawer.writeToLog(convertStreamToStr(shellIn));
        shellIn.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

public String convertStreamToStr(InputStream is) throws IOException{
    if(is != null){
        Writer writer = new StringWriter();

        char[] buffer = new char[1024];
        Reader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));
        int n;
        while((n = reader.read(buffer)) != -1){
            writer.write(buffer,0,n);
        }
        is.close();
        return writer.toString();
    }else{
        return "";
    }
}

If I try something like “ls” command it works fine. However, for my app I get this error:

./myApp: error while loading shared libraries: libcudart.so.5.0: cannot open shared object file: No such file or directory

CUDA is installed and properly configured in my machine, I can execute this app correctly from Terminal. I imagine that the error is from Java Virtual Machine.

How can I fix it?

  • 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-06-17T20:57:14+00:00Added an answer on June 17, 2026 at 8:57 pm

    This code works for me, I just tested it:

    System.out.printf("[Starter#main] !\n");
    final ProcessBuilder builder = new ProcessBuilder("absolute/path_to/your/executable");
    builder.redirectErrorStream(true);
    builder.environment().put("LD_LIBRARY_PATH",
        "/usr/local/cuda/lib64:/usr/local/cuda/lib");
    final Process start = builder.start();
    final InputStream outputStream = start.getInputStream();
    final BufferedReader reader = new BufferedReader(new InputStreamReader(outputStream));
    String s;
    while ((s = reader.readLine()) != null) {
        System.out.printf("[Starter#main] %s\n", s);
    }
    

    Gotchas:

    1. Make sure your application bitness matches your toolkit.
    2. Mac OS X variable is called “DYLD_LIBRARY_PATH”

    Also note:

    1. Spawned process will inherit environment from your Java process, that is it should work fine if you run Java application with PATH and LD_LIBRARY_PATH configured as advised by CUDA toolkit installer.
    2. You may externalize variables setting and launching your app in a shell script – then all you have to do is just running shell with a given script.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very precise question: I want to make an android application that
I have a very complex web app project I want to re-structure. Naturally, it
We have a very complex Oracle package here (over 4,100 lines of code) that's
I have a very complex Microsoft Access report. This report is run for multiple
I have a fairly complex business application written in ASP.NET that is deployed on
I have a very complex task - create a software that imports XMl files
I have a WPF application with a very complex XAMLs, I need a way
I have a very complex Linq to SQL query that returns a result set
I have a very large, complex (million+ LOC) Windows application written in C++. We
I have a very complex application (let's say enterprise application) deployed in Websphere 7

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.