473,467 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C++/Java integration

41 New Member
Hi!

I could try to explain what I would like to do, but I think a little code would be much easier to understand. So here goes:

C++ class:
Expand|Select|Wrap|Line Numbers
  1. class Cclass
  2. {
  3.   void some_C_function(int i)
  4.   {
  5.     printf("%d\n",i);
  6.   }
  7. };
  8.  
Java class:
Expand|Select|Wrap|Line Numbers
  1. Class Jclass extends Cclass
  2. {
  3.   public void some_Java_function(int i)
  4.   {
  5.     some_C_function(i);
  6.   }
  7. }
  8.  
C++ main:
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.   Jclass *j = new Jclass;
  4.   j->some_Java_function(5);
  5.  
  6.   return 0;
  7. }
  8.  
So i would like to be able to call c++ functions from java and java functions from c++. The reason for all this is that i would like to be able to use Java as a scripting language for my c++ program.

Maybe the java class should not extend the c++ class but have the function available in some other way?

I've read a little about CNI - but it seems that it only enables the calling of java methods from C++, and not the other way around.

So my questing is this: Can the above be done, or should I look into some other solution to the scripting language problem.

Thanks
Aug 11 '08 #1
4 2479
JonLT
41 New Member
I've found a thing called pawn - and it does what i want. Sorry about the fast posting.
Aug 11 '08 #2
gpraghuram
1,275 Recognized Expert Top Contributor
I've found a thing called pawn - and it does what i want. Sorry about the fast posting.

Is the pawn a open source tool?

Raghu
Aug 12 '08 #3
r035198x
13,262 MVP
...
Java class:
Expand|Select|Wrap|Line Numbers
  1. Class Jclass extends Cclass
  2. {
  3.   public void some_Java_function(int i)
  4.   {
  5.     some_C_function(i);
  6.   }
  7. }
  8.  
...
1.) Class declarations start with the keyword class (small c) not Class.
2.) Java is not a scripting language.
3.) If you want to call c/c++ functions from Java then google JNI.
Aug 12 '08 #4
JonLT
41 New Member
pawn is open source (zLib/libpng) and lets you call c++ functions from a pawn-script and also call functions in the script from c++.

The script is compiled using a pawn-compiler and is then executed in an abstract machine (from within the c++ source code).

The compiler is also open source so it can be implemented in the host application along with the abstract machine.
Aug 12 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: gohaku | last post by:
Hi everyone, I would like to know if it's possible to use python (libraries) in a Java Program. I do not want to use: Process proc = Runtime.getRuntime.exec(command) I am basically looking for...
14
by: Joachim Boomberschloss | last post by:
Hello, I am working on a project in Python, and I"m currently looking into the possibiliy of writing some of the project"s modules in Java. Given that a large part of the code is already...
9
by: CY FOK | last post by:
Hi I am planning to open a software company to develop client-server apps and web applications for my client. Now, i am in a difficult situation to determine what is the best platform i should use...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
2
by: Ad Bec | last post by:
I know that this question has probably been asked before but I am not in the mood to search the forums I am already tired of doing that. I need an answer for my What are Microsoft corp. plans...
0
by: Rithish | last post by:
OS : RHEL3 PHP version : 5.0.2 JDK version : 1.5.0.06 I have been trying to compile PHP with JAVA support for the past week, and all I have left to do is take a noose and hang myself. Of all...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
3
by: stien | last post by:
Hi, I'm looking for someon who can help me with a problem with the php/java integration...It just won't work.. Here are some data to describe the software/system I'm working with:...
3
by: Nishant | last post by:
Hi, I have to devlope a windows application with general functionality of Web Service Interaction, Office Integration and reporting. My expertise in both dot net and Java(Only Web application)....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.