473,396 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to used JAVA code in C++.

44
hi,

I am new in C++ programing and I wanted to know that is there any way to use java code in C++, I am somewhat familiar with "JNI" but using JNI we can use other ( C++ ) code in java reverse is not true.

Please suggest me.

Thanks in advance,
Abhinay
Jun 30 '08 #1
4 1561
Laharl
849 Expert 512MB
Um, JNI allows you to use Java code in C++, not the other way around. I don't think there's any way to use C++ inside the JVM, though you could of course spawn a child process.
Jun 30 '08 #2
weaknessforcats
9,208 Expert Mod 8TB
Generally, you cannout use Java code in C++. While the two languages appear similar in syntax they are really quite different and behave differently.

Such as:
1) no delegates in C++
2) Java methods become C++ inline functions
3) Java calls do not make a copies of the objects used on the call
4) there are no functions in Java. There are only methods of classes
5) Java is an object oriented language. C++ is a structured language with some object oriented features.
6) etc...

Sun designed Java to look like C++ in order to get C++ developers to abandon the public C++ in favor of Sun's proprietary Java by promising that Java didn't require nearly the skill to use as C++ but still didn't require the C++ developer to fundamentally abandon the familiar syntax of C++.
Jun 30 '08 #3
JosAH
11,448 Expert 8TB
You can go both ways using Java and C or C++. You can call C or C++ functions
from Java using JNI and you can also start the JVM from C or C++ and make Java
call C or C++ functions again using that same JNI framework. C or C++ functions
can call Java functions at will. Read the JNI documentation.

Of course you can't mix those languages by using both in a single compilation unit.

kind regards,

Jos
Jun 30 '08 #4
Abhinay
44
It will really help me lot !!!

Thank you ,
Abhinay.
Jul 7 '08 #5

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

Similar topics

0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
3
by: Hemant | last post by:
Hi all, I am very new to this HTML/JAVA environment. I am having some doubts please answer them ASAP. I want to run an executable from the browser iteself, without "Save" or "Open" and "Security...
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
61
by: Steven T. Hatton | last post by:
Stroustrup's view on classes, for the most part, seems to be centered around the notion of invariants. After a bit of adjusting to the use of yamt (yet another math term) in computer science, I...
5
by: Olaf Gschweng | last post by:
We're new into DB2 and have some problem with DB2 8.1 (?) on a Linux system. We load some big tables of a DB2 database from files every day. We do a "DELETE FROM table" for each table and then we...
4
by: m0002a | last post by:
I found a DB2 8.2 (FP8) instance running on AIX 5.2 where the dbm config JDK_PATH is set to a directory that does not exist. I can't even find any JDK installed on the server. What does DB2 do with...
8
by: Javier Martínez | last post by:
Hi Since a few months ago I have observed a change in the language used by MS people to write articles or to do presentations, before the change the language the more used was C# now the...
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
8
by: ssecorp | last post by:
I first learned about OO from Java. I much prefer to program in Python though. However I am consufed about 2 things. 1. Why do I have to pass self into every method in a class? Since I am...
5
by: bearophileHUGS | last post by:
I often use Python to write small programs, in the range of 50-500 lines of code. For example to process some bioinformatics data, perform some data munging, to apply a randomized optimization...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.