in Education by
I ran into a problem a few days ago when I had to introduce C++ files into a Java project. It started with a need to measure the CPU usage of the Java process and it was decided that the way to go was to use JNI to call out to a native library (a shared library on a Unix machine) written in C. The problem was to find an appropriate place to put the C files in the source repository (incidentally Clearcase) which consists of only Java files. I thought of a couple of alternatives: (a) Create a separate directory for putting the C files (specifically, one .h file and one .c file) at the top of the source base like: /vobs/myproduct/javasrc /vobs/myproduct/cppsrc I didn't like this because I have only two C files and it seemed very odd to split the source base at the language level like this. Had substantial portions of the project been written more or less equally in C++ and Java, this could be okay. (b) Put the C files into the Java package that uses it. I have the calling Java classes in /vobs/myproduct/com/mycompany/myproduct/util/ and the C files also go in there. I didn't like this either because I think the C files just don't belong in the Java package. Has anybody solved a problem like this before? Generally, what's a good strategy to follow when organizing codebase that mixes two or more languages? Update: I don't have any plan to use any C or C++ in my project, some Jython perhaps, but you never know when my customers need a feature that can be solved only by using C or best solved by using C. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
"I didn't like this because I have only two C files and it seemed very odd to split the source base at the language level like this" Why does it seem odd? Consider this project: project1\src\java project1\src\cpp project1\src\python Or, if you decide to split things up into modules: project1\module1\src\java project1\module1\src\cpp project1\module2\src\java project1\module2\src\python I guess it's a matter of personal taste, but the above structure is fairly common, and I think it works quite well once you get used to it.

Related questions

0 votes
    I ran into a problem a few days ago when I had to introduce C++ files into a Java project. It ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I ran into a problem a few days ago when I had to introduce C++ files into a Java project. It ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    Why apps developed in languages like C, C++ is prone to Buffer-overflow? (a) No string boundary checks in ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 4, 2021 in Education by JackTerrance
0 votes
    Can you execute javascript code from java 8 code base in Java8?...
asked Nov 8, 2020 in Education by Editorial Staff
0 votes
    Smart Contracts in R3 Corda are written using programming languages like ______ and _____. A. Go , C++ B. Java, Python C. Solidity, Vyper D. Java, Kotlin...
asked Feb 23, 2023 in Technology by JackTerrance
0 votes
    Applications developed by programming languages like ____ and ______ have this common buffer-overflow error. (a) C, Ruby ... questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 4, 2021 in Education by JackTerrance
0 votes
    when two operators like+,- share the same ranking the formula is calculate from right to left. is it true or false? Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    _________ refers to an undesirable state when a system attempts to perform two or more operations, which should, ... condition 2. Optimistic locking 3. Locking 4. Transaction...
asked Apr 12, 2021 in Technology by JackTerrance
0 votes
    What is the punishment in India for stealing computer documents, assets or any software's source code from any ... questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 4, 2021 in Education by JackTerrance
0 votes
    What is the name given to the base lining of the code in SVN?...
asked Feb 21, 2021 in Technology by JackTerrance
0 votes
    which two languages contributed to Python as a programming language Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
0 votes
    I'm working through my AI textbook I got and I've come to the last homework problem for my section: "Implement the ... in C# or Java? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
...