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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:12:15+00:00 2026-05-13T20:12:15+00:00

I’m trying to launch a Java app from a C++ app using the following

  • 0

I’m trying to launch a Java app from a C++ app using the following code:

#include <windows.h>
#include <memory.h>
#include <tchar.h>

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
    STARTUPINFOW        siStartupInfo;
    PROCESS_INFORMATION piProcessInfo;

    memset(&siStartupInfo, 0, sizeof(siStartupInfo));
    memset(&piProcessInfo, 0, sizeof(piProcessInfo)); 

    if (CreateProcess(TEXT("c:\\java\\jre\\bin\\java.exe"), TEXT("-jar testapp.jar"), NULL, NULL, false, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &siStartupInfo, &piProcessInfo) == false) {
        MessageBox(NULL, L"Could not load app", L"Error", 0);
    }

    CloseHandle(piProcessInfo.hProcess);
    CloseHandle(piProcessInfo.hThread);

    return 0;
}

When I build and run the program I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: testapp/jar
Caused by: java.lang.ClassNotFoundException: testapp.jar
        at: java.net.URLClassLoader$1.run(Uknown Source)
        at: java.security.AccessController.doPrivileged(Native Method)
        at: java.net.URLClassLoader.findClass(Uknown Source)
        at: java.lang.ClassLoader.loadClass(Uknown Source)
        at: sun.misc.Launcher$AppClassLoader.loadClass(Uknown Source)
        at: java.lang.ClassLoader.loadClass(Uknown Source)
Could not find the main class: testapp.jar. Program will exit.

The testapp.jar file is a runnable JAR file exported from an Eclipse project with a single class in it:

public class Test {
    public static void main(String[] args) {
        System.out.println("test");
    }
}

The EXE and JAR file are in the exact same folder, and I’m running the EXE from the command line. If I run the JAR directly by putting c:\java\jre\bin\java.exe -jar testapp.jar into the command-prompt everything works as expected.

Does anyone have any idea what’s going on here?

EDIT: Thank you all for your help, but it looks like I’ve got it working now.

  • 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-13T20:12:15+00:00Added an answer on May 13, 2026 at 8:12 pm

    Solved it. I used:

    if (CreateProcess(TEXT("C:\\Program Files\\Java\\jre6\\bin\\java.exe"), TEXT(" -jar test.jar"), NULL, NULL, false, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &siStartupInfo, &piProcessInfo) == false) {
            MessageBox(NULL, L"Could not load app", L"Error", 0);
        }
    

    Whereas you’ve used:

    if (CreateProcess(TEXT("C:\\Program Files\\Java\\jre6\\bin\\java.exe"), TEXT("-jar test.jar"), NULL, NULL, false, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &siStartupInfo, &piProcessInfo) == false) {
            MessageBox(NULL, L"Could not load app", L"Error", 0);
        }
    

    which, when I used it, replicates your error. The difference is a space preceding the -jar switch and why that should be, I don’t know, I stumbled upon it in error!

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

Sidebar

Ask A Question

Stats

  • Questions 424k
  • Answers 424k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ofcourse this has to be done manual, that's the whole… May 15, 2026 at 12:02 pm
  • Editorial Team
    Editorial Team added an answer I ended up using: <ul><?php wp_get_archives('type=daily'); ?></ul> It gave me… May 15, 2026 at 12:02 pm
  • Editorial Team
    Editorial Team added an answer Yes, Stream.ReadByte() will block until either: The stream is closed… May 15, 2026 at 12:02 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.