Tried as you said.
my jdk resides in C:\j2sdk1.4.2\bin and i have HelloWorld.java and HelloWorld.class inside the bin folder. I am able to run HelloWorld program in command using the following commands
cd C:\j2sdk1.4.2\bin
java -classpath . HelloWorld
It worked well and displayed HelloWorld.
When i tried calling HelloWorld program from C, it is not working and giving following error
Before calling java program
Exception in
thread "main" java.lang.NoClassDefFoundError: HelloWorld
status of system call1After calling java program
Call Java from C program
#include <stdio.h>
#include <stdlib.h>
int main()
{
int status = 0;
printf("Before calling java program\n");
system("cd C:\\j2sdk1.4.2\\bin");
status = system("java -classpath . HelloWorld");
printf("status of system call %d", status);
printf("After calling java program\n");
}
And my HelloWorld program for reference
public class HelloWorld {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello World");
}
}