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

Home Posts Topics Members FAQ

C wrapper for Java program?

I'm trying to write a C wrapper to run a Java program. I need to
distribute a CD with the Java runtime, my application and a C startup
program. I've put the C wrapper program, my java app and the runtime
directories in the same directory. It will run under MS XP or maybe
Vista. I'm using MS Visual C++ Express 2005 for a compiler and I tried
using the _execl and _spawnl functions. These all give me assertion
errors and file not found errors. There is some issue with the path.
Do _execl() and _spawnl() need absolute paths to the files? Any ideas
or directions would be greatly appreciated.

Thanks,

--

Knute Johnson
email s/nospam/knute/
Nov 1 '07 #1
16 3380
Knute Johnson wrote:
I'm trying to write a C wrapper to run a Java program. [..]
You could've stopped right there. Neither C nor Java are on topic
in comp.lang.C++. You see, the "plus-plus" is the difference.

Now, if your question is about the compiler or the OS-specific
functions, please RTFM or ask in the newsgroup where those are
topical.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 1 '07 #2
Victor Bazarov wrote:
Knute Johnson wrote:
>I'm trying to write a C wrapper to run a Java program. [..]

You could've stopped right there. Neither C nor Java are on topic
in comp.lang.C++. You see, the "plus-plus" is the difference.

Now, if your question is about the compiler or the OS-specific
functions, please RTFM or ask in the newsgroup where those are
topical.

V
Victor are you the local PITA? There is one in every newsgroup. Did
you not see I was using a C++ compiler to write the program. As far as
I know C is still a subset of C++. Go pound sand if you don't want to
be helpful.

Every program has to run on some OS and if asking how to write a wrapper
program with a C++ compiler isn't a C++ question then I will quietly
go away. Describing my environment was only to provide information that
might be necessary to my problem. I will happily accept a 'pure' C++
solution. Any assistance is greatly appreciated.

Thankyou,

--

Knute Johnson
email s/nospam/knute/
Nov 1 '07 #3
Knute Johnson wrote:
Victor Bazarov wrote:
>Knute Johnson wrote:
>>I'm trying to write a C wrapper to run a Java program. [..]

You could've stopped right there. Neither C nor Java are on topic
in comp.lang.C++. You see, the "plus-plus" is the difference.

Now, if your question is about the compiler or the OS-specific
functions, please RTFM or ask in the newsgroup where those are
topical.

V

Victor are you the local PITA?
Nope. He is a regular who has helped many people in the past.
There is one in every newsgroup. Did you not see I was using a C++
compiler to write the program.
What compiler you use is irrelevant for whether your question is topical.
As far as I know C is still a subset of C++.
Nit: It is not. There are many legal C programs that are illegal in C++ and
many legal C programs that happen to be legal C++, too, but have different
behavior when interpreted as C++ programs. There is, however, a non-empty
intersection of C and C++.
Go pound sand if you don't want to be helpful.

Every program has to run on some OS and if asking how to write a wrapper
program with a C++ compiler isn't a C++ question then I will quietly
go away. Describing my environment was only to provide information that
might be necessary to my problem. I will happily accept a 'pure' C++
solution. Any assistance is greatly appreciated.
Your specific question was:
I'm using MS Visual C++ Express 2005 for a compiler and I tried
using the _execl and _spawnl functions. These all give me assertion
errors and file not found errors. There is some issue with the path.
Do _execl() and _spawnl() need absolute paths to the files?
A search in my pdf-file of the C++ standard did not find _execl() nor
_spawnl(), and I also did not find it incorporated by reference from the C
standard. This pretty much is is the extend to which your question can be
answered topically in this forum. So in the end, Victor might be right and
you might be better off someplace where _execl() and _spawnl() are known.

On the other hand, you could just give absolute path names a try and see
whether that cures your problem.

Best

Kai-Uwe Bux

Nov 1 '07 #4
LR
Knute Johnson wrote:
Victor Bazarov wrote:
>Knute Johnson wrote:
>>I'm trying to write a C wrapper to run a Java program. [..]

You could've stopped right there. Neither C nor Java are on topic
in comp.lang.C++. You see, the "plus-plus" is the difference.

Now, if your question is about the compiler or the OS-specific
functions, please RTFM or ask in the newsgroup where those are
topical.

V

Victor are you the local PITA? There is one in every newsgroup. Did
you not see I was using a C++ compiler to write the program.
I don't think this is a true statement. If you want to write a C
language wrapper or any other kind of C language program, you are going
to use a C compiler. VS 2005 Express is an IDE. Not a compiler.
As far as
I know C is still a subset of C++.
I don't believe that is formally true, and depending on what version of
C you are speaking of, it may be less true now than it was.
Go pound sand if you don't want to
be helpful.


Every program has to run on some OS
I know from personal experience that this is not true. I've written
code that ran on machines with no OS.
and if asking how to write a wrapper program
In C.
with a C++ compiler
Doubtful.


isn't a C++ question then I will quietly go away.
I don't think there's any need to be quiet about it. But I honestly
don't think that you've asked a question about the C++ language. That's
what is on topic in this group. Yes, there are occasional exceptions.

Questions that are about specific compilers, even C++ compilers, are not
generally on topic here.
Describing my environment was only to provide information that
might be necessary to my problem.
I think that you will probably find more help in a group devoted to your
compiler.
I will happily accept a 'pure' C++ solution.
For reasons that I think are as yet unknown, at least to me,
www.parashift.com is down, but according to a recent post you can see
here, http://groups.google.com/group/comp....d88a0d48be6eec
the most recent copy of the FAQ is here
http://www.cs.technion.ac.il/users/y.../FAQs/c++-faq/

You can read more about where to get help with your particular problem
here
http://www.cs.technion.ac.il/users/y...t.html#faq-5.9
Any assistance is greatly appreciated.
HTH

LR
Nov 1 '07 #5
Kai-Uwe Bux wrote:
Knute Johnson wrote:
>Victor Bazarov wrote:
>>Knute Johnson wrote:
I'm trying to write a C wrapper to run a Java program. [..]
You could've stopped right there. Neither C nor Java are on topic
in comp.lang.C++. You see, the "plus-plus" is the difference.

Now, if your question is about the compiler or the OS-specific
functions, please RTFM or ask in the newsgroup where those are
topical.

V
Victor are you the local PITA?

Nope. He is a regular who has helped many people in the past.
>There is one in every newsgroup. Did you not see I was using a C++
compiler to write the program.

What compiler you use is irrelevant for whether your question is topical.
>As far as I know C is still a subset of C++.

Nit: It is not. There are many legal C programs that are illegal in C++ and
many legal C programs that happen to be legal C++, too, but have different
behavior when interpreted as C++ programs. There is, however, a non-empty
intersection of C and C++.
>Go pound sand if you don't want to be helpful.

Every program has to run on some OS and if asking how to write a wrapper
program with a C++ compiler isn't a C++ question then I will quietly
go away. Describing my environment was only to provide information that
might be necessary to my problem. I will happily accept a 'pure' C++
solution. Any assistance is greatly appreciated.

Your specific question was:
>I'm using MS Visual C++ Express 2005 for a compiler and I tried
using the _execl and _spawnl functions. These all give me assertion
errors and file not found errors. There is some issue with the path.
Do _execl() and _spawnl() need absolute paths to the files?

A search in my pdf-file of the C++ standard did not find _execl() nor
_spawnl(), and I also did not find it incorporated by reference from the C
standard. This pretty much is is the extend to which your question can be
answered topically in this forum. So in the end, Victor might be right and
you might be better off someplace where _execl() and _spawnl() are known.

On the other hand, you could just give absolute path names a try and see
whether that cures your problem.
OK, I'm sorry I even mentioned C. I won't do it again.

As to _execl and _spawnl, those are methods I tried unsuccessfully. I
did try absolute path names by the way. I thought mentioning what I had
tried would be of some interest to whoever wanted to give me some help.

I'm still interested in writing a wrapper for my Java program. If that
is not possible with C++ then feel free to say so.

If this forum is only for discussing pure C++, no OS, no compiler, no
environment and you are not interested in helping me out then please
excuse me for bothering you.

--

Knute Johnson
email s/nospam/knute/
Nov 1 '07 #6
LR wrote:
Knute Johnson wrote:
>Victor Bazarov wrote:
>>Knute Johnson wrote:
I'm trying to write a C wrapper to run a Java program. [..]

You could've stopped right there. Neither C nor Java are on topic
in comp.lang.C++. You see, the "plus-plus" is the difference.

Now, if your question is about the compiler or the OS-specific
functions, please RTFM or ask in the newsgroup where those are
topical.

V

Victor are you the local PITA? There is one in every newsgroup. Did
you not see I was using a C++ compiler to write the program.

I don't think this is a true statement. If you want to write a C
language wrapper or any other kind of C language program, you are going
to use a C compiler. VS 2005 Express is an IDE. Not a compiler.
It has a C++ compiler.
As far as
I know C is still a subset of C++.

I don't believe that is formally true, and depending on what version of
C you are speaking of, it may be less true now than it was.
Go pound sand if you don't want to
be helpful.
I'll agree with my pre-response here.
>Every program has to run on some OS

I know from personal experience that this is not true. I've written
code that ran on machines with no OS.
C++ code?
and if asking how to write a wrapper program

In C.
with a C++ compiler

Doubtful.
I have a C++ compiler, I came to a C++ forum. I think I want to write
it in C++.
>isn't a C++ question then I will quietly go away.

I don't think there's any need to be quiet about it. But I honestly
don't think that you've asked a question about the C++ language. That's
what is on topic in this group. Yes, there are occasional exceptions.

Questions that are about specific compilers, even C++ compilers, are not
generally on topic here.
Describing my environment was only to provide information that
might be necessary to my problem.

I think that you will probably find more help in a group devoted to your
compiler.
>I will happily accept a 'pure' C++ solution.

For reasons that I think are as yet unknown, at least to me,
www.parashift.com is down, but according to a recent post you can see
here, http://groups.google.com/group/comp....d88a0d48be6eec
the most recent copy of the FAQ is here
http://www.cs.technion.ac.il/users/y.../FAQs/c++-faq/

You can read more about where to get help with your particular problem
here
http://www.cs.technion.ac.il/users/y...t.html#faq-5.9

Any assistance is greatly appreciated.

HTH

LR
Thanks very much for the list of newsgroups. That may be the most
helpful hint I've received here.

--

Knute Johnson
email s/nospam/knute/
Nov 1 '07 #7
Knute Johnson wrote:
[..]
If this forum is only for discussing pure C++, no OS, no compiler, no
environment and you are not interested in helping me out then please
excuse me for bothering you.
You're excused.

If you need help with OS, post to the newsgroup dedicated to that OS.

If you need help with your compiler, post to the newsgroup dedicated
to that compiler.

If you need help with the environment... What environment do you mean?
We recycle.

We are interested in "helping you out" if you have a C++ *LANGUAGE*
problem. And I believe we _are_ helping you out by telling you that
you're in the wrong place, otherwise you don't even know you're lost.

See http://www.new-brunswick.net/workshop/c++/faq/ , section 5.
And read the Welcome message 'Shiva' and 'arnuld' have posted here.

All the best!

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 1 '07 #8
Victor Bazarov wrote:
Knute Johnson wrote:
>[..]
If this forum is only for discussing pure C++, no OS, no compiler, no
environment and you are not interested in helping me out then please
excuse me for bothering you.

You're excused.

If you need help with OS, post to the newsgroup dedicated to that OS.

If you need help with your compiler, post to the newsgroup dedicated
to that compiler.

If you need help with the environment... What environment do you mean?
We recycle.

We are interested in "helping you out" if you have a C++ *LANGUAGE*
problem. And I believe we _are_ helping you out by telling you that
you're in the wrong place, otherwise you don't even know you're lost.

See http://www.new-brunswick.net/workshop/c++/faq/ , section 5.
And read the Welcome message 'Shiva' and 'arnuld' have posted here.

All the best!

V
Just so I'm clear, you are telling me that C++ has no way of spawning
another program?

Thanks,

--

Knute Johnson
email s/nospam/knute/
Nov 1 '07 #9
Knute Johnson wrote:
Kai-Uwe Bux wrote:
>Knute Johnson wrote:
>>Victor Bazarov wrote:
Knute Johnson wrote:
I'm trying to write a C wrapper to run a Java program. [..]
You could've stopped right there. Neither C nor Java are on topic
in comp.lang.C++. You see, the "plus-plus" is the difference.

Now, if your question is about the compiler or the OS-specific
functions, please RTFM or ask in the newsgroup where those are
topical.

V
Victor are you the local PITA?

Nope. He is a regular who has helped many people in the past.
>>There is one in every newsgroup. Did you not see I was using a C++
compiler to write the program.

What compiler you use is irrelevant for whether your question is topical.
>>As far as I know C is still a subset of C++.

Nit: It is not. There are many legal C programs that are illegal in C++
and many legal C programs that happen to be legal C++, too, but have
different behavior when interpreted as C++ programs. There is, however, a
non-empty intersection of C and C++.
>>Go pound sand if you don't want to be helpful.

Every program has to run on some OS and if asking how to write a wrapper
program with a C++ compiler isn't a C++ question then I will quietly
go away. Describing my environment was only to provide information that
might be necessary to my problem. I will happily accept a 'pure' C++
solution. Any assistance is greatly appreciated.

Your specific question was:
>>I'm using MS Visual C++ Express 2005 for a compiler and I tried
using the _execl and _spawnl functions. These all give me assertion
errors and file not found errors. There is some issue with the path.
Do _execl() and _spawnl() need absolute paths to the files?

A search in my pdf-file of the C++ standard did not find _execl() nor
_spawnl(), and I also did not find it incorporated by reference from the
C standard. This pretty much is is the extend to which your question can
be answered topically in this forum. So in the end, Victor might be right
and you might be better off someplace where _execl() and _spawnl() are
known.

On the other hand, you could just give absolute path names a try and see
whether that cures your problem.

OK, I'm sorry I even mentioned C. I won't do it again.

As to _execl and _spawnl, those are methods I tried unsuccessfully. I
did try absolute path names by the way. I thought mentioning what I had
tried would be of some interest to whoever wanted to give me some help.

I'm still interested in writing a wrapper for my Java program. If that
is not possible with C++ then feel free to say so.
As far as I know, standard C++ has only one method to start another program,
and that is system(). That allows you to run a command, but it does not
even allow you to capture the output in a string or something like that.

Also, as of now now the C++ is not thread-aware, in case that matters.

If this forum is only for discussing pure C++, no OS, no compiler, no
environment
That pretty much sums it up.
and you are not interested in helping me out then please
excuse me for bothering you.
Well, we are interested in helping you. It just so happens that for your
particular problem, the use of non-standard and platform-specific libraries
seems to be the way to go. Those libraries in turn are off-topic here and
hopefully there are other forums where they are being discussed.

On the other hand, whether the lack of support for such tasks in the
standard is a good thing or a bad thing about C++ would be topical here,
but likely to cause a flame war :-)
Best

Kai-Uwe Bux
Nov 1 '07 #10
"Knute Johnson" <no****@rabbitbrush.frazmtn.comwrote in message
news:mk**************@newsfe16.lga...
Victor Bazarov wrote:
>Knute Johnson wrote:
>>[..]
If this forum is only for discussing pure C++, no OS, no compiler, no
environment and you are not interested in helping me out then please
excuse me for bothering you.

You're excused.

If you need help with OS, post to the newsgroup dedicated to that OS.

If you need help with your compiler, post to the newsgroup dedicated
to that compiler.

If you need help with the environment... What environment do you mean?
We recycle.

We are interested in "helping you out" if you have a C++ *LANGUAGE*
problem. And I believe we _are_ helping you out by telling you that
you're in the wrong place, otherwise you don't even know you're lost.

See http://www.new-brunswick.net/workshop/c++/faq/ , section 5.
And read the Welcome message 'Shiva' and 'arnuld' have posted here.

All the best!

V

Just so I'm clear, you are telling me that C++ has no way of spawning
another program?
Standard C++ has no way of spawning another program. Your operating system
might, however, and your compiler writers may include a non standard
function call to spawn another program. But that is not part of the
standard C++ implementation and is specific to your operating
system/compiler. It is done differently on Linux than on Windows than on
Apple OS than on OS400 etc...
Nov 1 '07 #11
On 2007-11-01 22:13, Knute Johnson wrote:
Victor Bazarov wrote:
>Knute Johnson wrote:
>>[..]
If this forum is only for discussing pure C++, no OS, no compiler, no
environment and you are not interested in helping me out then please
excuse me for bothering you.

You're excused.

If you need help with OS, post to the newsgroup dedicated to that OS.

If you need help with your compiler, post to the newsgroup dedicated
to that compiler.

If you need help with the environment... What environment do you mean?
We recycle.

We are interested in "helping you out" if you have a C++ *LANGUAGE*
problem. And I believe we _are_ helping you out by telling you that
you're in the wrong place, otherwise you don't even know you're lost.

See http://www.new-brunswick.net/workshop/c++/faq/ , section 5.
And read the Welcome message 'Shiva' and 'arnuld' have posted here.

All the best!

V

Just so I'm clear, you are telling me that C++ has no way of spawning
another program?
C++ as in "the C++ language", well you could use system() but I
generally discourage the use of that. On the other hand there might be a
number of platform-specific libraries or other third part libraries
which provides the ability to spawning other processes.

On most platforms you can find the POSIX compliant execl(), execv(),
execlp(), and execvp() functions. As you discovered they also exist on
Windows (though MS added an underscore in front). But to get help about
using them you should ask in a group discussing programming on your
platform.

--
Erik Wikström
Nov 1 '07 #12
On 2007-11-01 20:45, Knute Johnson wrote:
LR wrote:
>Knute Johnson wrote:
>>Every program has to run on some OS

I know from personal experience that this is not true. I've written
code that ran on machines with no OS.

C++ code?
Yes, that is what the standard calls a freestanding implementation. One
good example is the Windows kernel, which I have heard is written (at
least partly) in C++.

--
Erik Wikström
Nov 1 '07 #13
LR
Knute Johnson wrote:

Just so I'm clear, you are telling me that C++ has no way of spawning
another program?
Standard C++? Not to my knowlege. And AFAIK, the C++ standard does not
include the functions that you asked about, _execl and _spawnl.

AFAIK, There is no limitation on vendors that suggests that they cannot
implement these functions and ship them in a lib with their compilers.

Perhaps your IDE ships with an extensive help system that contains
references for these platform specific functions and sample code that
will show you how to use it?
Elsethread, you also asked me if I had specifically written code in C++
that ran on a platform without an OS. No. I haven't, but the 2007 draft
standard had this to say on the subject, at least at the time I
downloaded it:

"Two kinds of implementations are defined: hosted and freestanding. For
a hosted implementation, this International Standard defines the set of
available libraries. A freestanding implementation is one in which
execution may take place without the benefit of an operating system, and
has an implementation-defined set of libraries that includes certain
language-support libraries [...]"

So it seems reasonable to me that someone, somewhere is writing C++ code
that will run on a platform with no OS.

Also, may I point out, that an OS is just a program, often largely
written in a language like C or C++, and unless you are deploying the OS
on a VM, the OS will run on a platform that doesn't have an OS.

Thanks,
My pleasure.

LR

Nov 1 '07 #14
Kai-Uwe Bux wrote:
As far as I know, standard C++ has only one method to start another program,
and that is system(). That allows you to run a command, but it does not
even allow you to capture the output in a string or something like that.
I don't need the output, I just want to start the other program. So
could the system() method be used to start my java interpreter?

Could you point me to a copy of the C++ standard or maybe post a snippet
of the docs for system()?

Thanks,

--

Knute Johnson
email s/nospam/knute/
Nov 2 '07 #15
"Knute Johnson" <no****@rabbitbrush.frazmtn.comwrote in message
news:_X**************@newsfe16.lga...
Kai-Uwe Bux wrote:
>As far as I know, standard C++ has only one method to start another
program,
and that is system(). That allows you to run a command, but it does not
even allow you to capture the output in a string or something like that.

I don't need the output, I just want to start the other program. So could
the system() method be used to start my java interpreter?

Could you point me to a copy of the C++ standard or maybe post a snippet
of the docs for system()?
system("myprogram.exe -flags");
Nov 2 '07 #16
Jim Langston wrote:
"Knute Johnson" <no****@rabbitbrush.frazmtn.comwrote in message
news:_X**************@newsfe16.lga...
>Kai-Uwe Bux wrote:
>>As far as I know, standard C++ has only one method to start another
program,
and that is system(). That allows you to run a command, but it does not
even allow you to capture the output in a string or something like that.
I don't need the output, I just want to start the other program. So could
the system() method be used to start my java interpreter?

Could you point me to a copy of the C++ standard or maybe post a snippet
of the docs for system()?

system("myprogram.exe -flags");

That works great. Thanks very much.

--

Knute Johnson
email s/nospam/knute/
Nov 2 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Java and Swing | last post by:
static PyObject *wrap_doStuff(PyObject *self, PyObject *args) { // this will store the result in a Python object PyObject *finalResult; // get arguments from Python char *result = 0; char *in=...
5
by: niidjan | last post by:
I would like to know more about C++ wrappers. What is a wrapper object in C++ and why is it neccessary? I am trying to create a templated linked list data structure to store any object or primitive...
15
by: Steve Richfield | last post by:
To All, First, some of your replies to me have been posted through DevelopersDex, and these are NOT posted on USENET for the world to see. DevelopersDex appears to be trying to hijack USENET,...
2
by: GinTon | last post by:
EyeDB is a free ODBMS based on the ODMG 3 specification with programming interfaces for C++ and Java. It is very powerfull, mature, safe and stable. In fact, it was developed in 1992 for the Genome...
2
by: =?Utf-8?B?cGh5cw==?= | last post by:
I need to write a C# application that uses unmanaged C++ code. I created a C++/CLI wrapper to C++ code and encountered the following problem. Any time I try to instantiate a wrapper in C#...
2
by: Toby | last post by:
I'm trying to write a simple commandline wrapper: a script that runs another program as a child and relays unbuffered stdin and stdout to/from the child process, possibly filtering it. The...
1
by: Tony Freixas | last post by:
Hello, I'm trying to create a wrapper for a program. I want to execute program 'X' by running program 'Y', such that 'Y' appears to function pretty much like 'X' both in the way command line...
8
by: Seth7TS | last post by:
Hi everyone, i need to make a protection for a fortran software(a line command in linux). My desire is to write a C wrapper that control the execution of the program. Can someone help me? i dont...
24
by: Peter Michaux | last post by:
I have a Perl script that I want to run as a set-user-ID program. Many OSes don't allow scripts run as set-user-ID. To make this script portable, it seems I need to write a C wrapper program that...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
1
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...
1
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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.