Find the answer to your Linux question:
Results 1 to 4 of 4
I want to run a java application(.class) through c++ code . What are the commands to do that?...
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Posts
    2

    how to run java application through c++ code?

    I want to run a java application(.class) through c++ code . What are the commands to do that?

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    C++\Java

    try googling cygnus native interface CNI.

    This can be used to access java classes from C++.

  3. #3
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    I am not sure if I understand your question properly.

    If you mean "compile java code using the g++ compiler, then it can't be done. The g++ compiler only compiles c++ code, which is similar to java son some things, but it's not quite the same.

    If you really want to compile java code to machine code, look into gcj. gcj can compile java to bytecode or to machine code, and it can compile bytecode to machine native code as well.

    If you meant that you want to use java classes from a C++ program, then look at the solution that gerard4143 gave you. I never did that so I can't help there.

  4. #4
    Just Joined!
    Join Date
    Jun 2008
    Posts
    2

    Thank you Gerard!

    Thank you gerard and i92guboj
    But I found another way by using fork() and execve() commands in my C++ code which can be used to execute any other program...That is much easier than using CNI/GCJ.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...