C wrapper for Java program?

K

Knute Johnson

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,
 
V

Victor Bazarov

Knute said:
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
 
K

Knute Johnson

Victor said:
Knute said:
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,
 
K

Kai-Uwe Bux

Knute said:
Victor said:
Knute said:
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
 
L

LR

Knute said:
Victor said:
Knute said:
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.lang.c++/msg/6ed88a0d48be6eec
the most recent copy of the FAQ is here
http://www.cs.technion.ac.il/users/yechiel/CS/FAQs/c++-faq/

You can read more about where to get help with your particular problem
here
http://www.cs.technion.ac.il/users/yechiel/CS/FAQs/c++-faq/how-to-post.html#faq-5.9
> Any assistance is greatly appreciated.

HTH

LR
 
K

Knute Johnson

Kai-Uwe Bux said:
Knute said:
Victor said:
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.
 
K

Knute Johnson

LR said:
Knute said:
Victor said:
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.
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.

I'll agree with my pre-response here.
I know from personal experience that this is not true. I've written
code that ran on machines with no OS.

C++ code?
In C.


Doubtful.

I have a C++ compiler, I came to a C++ forum. I think I want to write
it in C++.
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.


I think that you will probably find more help in a group devoted to your
compiler.


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.lang.c++/msg/6ed88a0d48be6eec
the most recent copy of the FAQ is here
http://www.cs.technion.ac.il/users/yechiel/CS/FAQs/c++-faq/

You can read more about where to get help with your particular problem
here
http://www.cs.technion.ac.il/users/yechiel/CS/FAQs/c++-faq/how-to-post.html#faq-5.9



HTH

LR

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

Victor Bazarov

Knute said:
[..]
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
 
K

Knute Johnson

Victor said:
Knute said:
[..]
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,
 
K

Kai-Uwe Bux

Knute said:
Kai-Uwe Bux said:
Knute said:
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
 
J

Jim Langston

Knute Johnson said:
Victor said:
Knute said:
[..]
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...
 
G

Guest

Victor said:
Knute said:
[..]
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.
 
G

Guest

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++.
 
L

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.


My pleasure.

LR
 
K

Knute Johnson

Kai-Uwe Bux said:
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,
 
J

Jim Langston

Knute Johnson said:
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");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top