0
votes

I'm tring to run jar file from C++

I wrote this code:

#include "stdafx.h"
#include <iostream>
#include <strsafe.h>
#include <stdexcpt.h>
#include "jni.h"
#include <conio.h>
#include <Windows.h>
using namespace std;

#pragma comment (lib,"C:\\Users\\Hilla\\Documents\\Visual Studio 2012\\helloworld\\helloworld\\jvm.lib")

int main()

{  
    JavaVM *jvm;
    JNIEnv *env;
    JavaVMInitArgs vm_args;

    JavaVMOption options[3];
    options[0].optionString = "-Djava.compiler=NONE";
    options[1].optionString="-Djava.class.path=C:\\Users\\Hilla\\Documents\\Visual      
        Studio 2012\\helloworld\\Debug\\hello.jar";
    options[2].optionString="verbose.jni";
    vm_args.version=JNI_VERSION_1_6;
    vm_args.nOptions=3;
    vm_args.options=options;
    vm_args.ignoreUnrecognized=0;
    int ret=JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
    printf("hilla");



}

I work with the x64 compiler. I add the JVM lim to the system path.

And it's still giving me this error:

'helloworld.exe' (Win32): Loaded 'C:\Users\Hilla\Documents\Visual Studio 2012\helloworld\x64\Debug\helloworld.exe'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Program Files\Java\jdk1.7.0_45\jre\bin\server\jvm.dll'. Cannot find or open the PDB file.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\msvcp110d.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\msvcr110d.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\wsock32.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\winmm.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\psapi.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\msvcr100.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\winmmbase.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\nsi.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\devobj.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\msctf.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\nvinitx.dll'. Cannot find or open the PDB file.
'helloworld.exe' (Win32): Loaded 'C:\Program Files\NVIDIA Corporation\coprocmanager\detoured.dll'. Cannot find or open the PDB file. 'helloworld.exe' (Win32): Loaded 'C:\Program Files\NVIDIA Corporation\coprocmanager\Nvd3d9wrapx.dll'. Cannot find or open the PDB file.
'helloworld.exe' (Win32): Loaded 'C:\Windows\System32\setupapi.dll'. Symbols loaded.
'helloworld.exe' (Win32): Loaded 'C:\Program Files\NVIDIA Corporation\coprocmanager\nvdxgiwrapx.dll'. Cannot find or open the PDB file.

The program '[7688] helloworld.exe' has exited with code 0 (0x0).

How can I fix this?

1
I doubt that the nVidia dlls have pdb files so you will not be able to debug these as easily. Although do you really need to understand what is going on inside your GPU drivers?drescherjm
What is the actual problem?drescherjm
int ret=JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args); returns -1?user3130432
You have a space in the java class path. Does that need to be enclosed in quotes?drescherjm
Since I have not studied java in 20 years I do not remember. Does the java class path variable require a quoted string on paths that contain a space or will the JavaVMOption take care of that. My suspicion is the jvm is not finding the jar file because of the space in the path.drescherjm

1 Answers

-1
votes

PDB is a debug information file used by Visual Studio. These are system DLLs, which you don't have debug symbols. Go to Tools->Options->Debugging->Symbols and select checkbox Microsoft Symbol Servers, Visual Studio will download PDBs automatically.

Please read a similar question posted for VS 2010 here