I try to be more specific now: In VC++ I define a OnButtonClick
method. Once the button is clicked, a piece of JAVA-code in a file
must be loaded and compiled using a Java-Compiler (javac). The Java
program returns an integer, say. A Java-example may be this:
public class Main {
public Main() {
}
public static void main(String[] args) {
try{
MCDVersion pMCDVersion = new MCDVersion();
int major = pMCDVersion.getMajor();
} catch (com.inzoom.comjni.ComJniException e){
System.err.println("Exception: "+e.getMessage());
}
}
}
The desired result is in major. After having compiled this code from
C++, it must be executed in order to get the value of major. Then I
would like to pass this integer (that was generated from the Java
code) back to C++, and C++ uses it further. Here is my OnButtonClick
method:
void CTestDlg::OnButtonClick()
{
...
// compile Main.java
system("javac C:\\TEST\\Main.java");
// run Main.class
system("java C:\\TEST\\Main");
...
}
Questions are this: Is this the best way to do it? Secondly, how do
I pass the integer result to C++ so that it can be used again?
Thanks again. 2 1652
ToSam wrote: I try to be more specific now: In VC++ I define a OnButtonClick method. Once the button is clicked, a piece of JAVA-code in a file must be loaded and compiled using a Java-Compiler (javac). The Java program returns an integer, say. A Java-example may be this:
public class Main {
public Main() { }
public static void main(String[] args) {
try{
MCDVersion pMCDVersion = new MCDVersion(); int major = pMCDVersion.getMajor();
} catch (com.inzoom.comjni.ComJniException e){ System.err.println("Exception: "+e.getMessage()); } } }
The desired result is in major. After having compiled this code from C++, it must be executed in order to get the value of major. Then I would like to pass this integer (that was generated from the Java code) back to C++, and C++ uses it further. Here is my OnButtonClick method:
void CTestDlg::OnButtonClick() { ... // compile Main.java system("javac C:\\TEST\\Main.java"); // run Main.class system("java C:\\TEST\\Main"); ... }
Questions are this: Is this the best way to do it? Secondly, how do I pass the integer result to C++ so that it can be used again?
Thanks again.
In c++ standard there is no way you can invoke some other compiler to
run and get the results from the different language. Your solution of
using system() is not standard C++. It is operating system specific
call. Please go to the appropriate newsgroup to solve your problem.
Regards
Shan
ToSam wrote: I try to be more specific now: In VC++ I define a OnButtonClick method. Once the button is clicked, a piece of JAVA-code in a file must be loaded and compiled using a Java-Compiler (javac). The Java program returns an integer, say. A Java-example may be this:
public class Main {
public Main() { }
public static void main(String[] args) {
try{
MCDVersion pMCDVersion = new MCDVersion(); int major = pMCDVersion.getMajor();
} catch (com.inzoom.comjni.ComJniException e){ System.err.println("Exception: "+e.getMessage()); } } }
The desired result is in major. After having compiled this code from C++, it must be executed in order to get the value of major. Then I would like to pass this integer (that was generated from the Java code) back to C++, and C++ uses it further. Here is my OnButtonClick method:
void CTestDlg::OnButtonClick() { ... // compile Main.java system("javac C:\\TEST\\Main.java"); // run Main.class system("java C:\\TEST\\Main"); ... }
Questions are this: Is this the best way to do it? Secondly, how do I pass the integer result to C++ so that it can be used again?
off topic, but..as you might have guessed, this is not the way to do it.
You probably need JINI.
--
- gipsy boy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ravi Tallury |
last post by:
Hi
We are having issues with our application, certain portions of it stop
responding while the rest of the application is fine. I am attaching
the Java Core dump. If someone can let me know what...
|
by: ptaz |
last post by:
Hi I'm trying to run a web page but I get the following error. Ca
anyone please tell me a solution to this.
Thanks
Ptaz
HTTP Status 500 -
type Exception report
|
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...
|
by: mailkhurana |
last post by:
Hii ,
I am trying to use a type 2 driver to connect to DB2 0n AIX 5
I have a small java test to class to establish a conneciton with the db
.. I am NOT using WAS or any appserver
When I try to...
|
by: David Van D |
last post by:
Hi there,
A few weeks until I begin my journey towards a degree in Computer
Science at Canterbury University in New Zealand,
Anyway the course tutors are going to be teaching us JAVA wth bluej...
|
by: Mark Fink |
last post by:
I wrote a Jython class that inherits from a Java class and (thats the
plan) overrides one method. Everything should stay the same.
If I run this nothing happens whereas if I run the Java class it...
|
by: jaywak |
last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build...
|
by: jaimemartin |
last post by:
hello,
I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
|
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);
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
|
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...
|
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,...
| |