• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

c/c++ from Java

 
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know how to run c/c++ code from Java program.
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am certain that this is not part of the SCWCD certification (which this forum is all about)

The JNI API can be used to call C/C++ code from Java.
 
Swapnil Sanghai
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used the JNI but it shows me an error as can't find the class file. Means when I compile the .java file it creates the .class file with no error or exception but when I try to make the header file using "javah" it is telling that he couldn't find the required class file. I placed .java and .class file in the same directory.
 
Tim Moores
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to work through a JNI introduction like http://www.ibm.com/developerworks/java/tutorials/j-jni/ or http://www.javaworld.com/javaworld/jw-10-1999/jw-10-jni.html. After that, things should become clearer.

PS: Strange URL of this topic: ".../java/java/java". SEO at work?
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.lang.Runtime.exec("C:\\Programs\\MyCPlusPlusProgram.exe");
 
Swapnil Sanghai
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jimmy. Thanks everyone.
 
Swapnil Sanghai
Ranch Hand
Posts: 52
Oracle Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Jimmy:
When I run the code using the Runtime object as you said it gives me error telling that


C:\WINDOWS\system32\ntvdm.exe
Error while setting up environment for application. Choose close to terminate the application.

I am running the program on windows XP and I used TC compiler for the C program. Please tell me what is the cause.
 
reply
    Bookmark Topic Watch Topic
  • New Topic