Results 1 to 6 of 6

Thread: C++ as native code in java

  1. #1
    Join Date
    Dec 2009
    Posts
    292

    C++ as native code in java

    Hello,
    I have a C + + code that I want to connect it to Java, but I stumbled on the use of a body which is declared in a large file header and create in the hand.
    test.h:
    Code:
    extern mtype mnInst *;
    main.cpp:
    Code:
    mtype mnInst *;
    If you have any idea of how to do it , then please let me know i am the interested one. Thanks in advance.

  2. #2
    Join Date
    Nov 2009
    Posts
    356

    Re: C++ as native code in java

    Hello,
    Here, we do not necessarily know the C++ code.
    From what you have explained and what I have understood from is explanation, then we have two solutions.
    - put this thing in the system properties,
    - put this thing in a ThreadLocal.

    Already, look what you think best, why, if you get it to work, and if you can not do it, tell us, from there we can advise you on the path you have chosen.

  3. #3
    Join Date
    Nov 2009
    Posts
    446

    Re: inlcuding c++ header file in java

    Hello,
    I think of 2 solutions:

    - Pass in the creation of each object using mnInst reference on this subject. This is not really feasible because among other things have got a fiddled.

    - Declare all methods and static variables in order to call all the class but long term I might have several threads that will be almost the same thing but will have different values.

    Hope one of these solution will work for you. If you have any other queries then you can ask.

  4. #4
    Join Date
    Nov 2009
    Posts
    347

    Re: C++ as native code in java

    Hello,
    In c++ the keyword 'extern' can validate the syntax in believing that "something" (type, variable, macro, etc..). Thus there is no compilation error in a separate compilation (. O. So. Dll). The connection will be done either dynamically (. So. Dll), or to ESTABLISH the executable from. Under this system of Java it is not compiled for a class, the compiler must know the class which is being called. For its execution, the connection is dynamic. I hope you are understanding the things and the concept clearly here, otherwise you will be in a trouble of coding for your program.

  5. #5
    Join Date
    Nov 2009
    Posts
    583

    Re: C++ as native code in java

    Hello,
    In passing it can quickly become a nice "mess" when it falls on a name conflict. In Java we would use a static variable:
    Here is the sample or the syntax for the static code
    Code:
    Public class mclass {
        Public static int mvar = 0;
    }
    I think you should use this in your java code, this is a good option for me, and also it works without any problem.

  6. #6
    Join Date
    Dec 2009
    Posts
    292

    Re: C++ as native code in java

    Hello,
    Thank you for your replies. Finally I have decided to use a class variable. At this point, if I'm running multiple instances of my program is that the class variable will be shared by multiple instances of the program or that it is well separated in the JVM? Any help on this topic rather being more precisely the java JVM, I would like to know more about it. Any help on it is appreciated. Thanks in advance.

Similar Threads

  1. Replies: 3
    Last Post: 02-02-2012, 01:57 AM
  2. help me to understand java code (calendar java code) ?
    By so0oma in forum Software Development
    Replies: 2
    Last Post: 10-01-2011, 12:01 AM
  3. Use Java code in PHP
    By Gajendra1 in forum Software Development
    Replies: 6
    Last Post: 12-08-2010, 10:18 AM
  4. Native methods of java
    By Truster in forum Software Development
    Replies: 5
    Last Post: 22-01-2010, 10:52 AM
  5. Google Native Client: x86 code in Web applications
    By monsitj in forum Technology & Internet
    Replies: 2
    Last Post: 26-02-2009, 10:04 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,530,870.33802 seconds with 17 queries