C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 24th, 2003, 02:48 PM
lenochka lenochka is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 11 lenochka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question error specifying path for CreateProcess

Hi Everyone,

Can someone please help me with this problem, Thanks ahead of time:
I am trying to use CreateProcess() to launch a java
executable and then wait for it to terminate. This is what
my code looks like:

NIpath = "java -
classpath .;ni.jar;lib\\snmp4_13.jar;lib\\comm.jar;lib\\tab
lelayout.jar;lib\\jaxb\\jax-qname.jar;lib\\jaxb\\jaxb-
api.jar;lib\\jaxb\\jaxb-libs.jar;lib\\jaxb\\jaxb-
ri.jar;lib\\jaxb\\jaxb-xjc.jar;lib\\jaxb\\namespace.jar
com.ni.NI";

createProcessStatus = CreateProcess(NULL, NIpath, NULL,
NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);

(There is a space between the long string after -classpath and "com.ni.NI")
The problem is with NIpath. CreateProcess executes without
error if the com.ni.NI executable is in
the same directory as my program's executable, however as
soon as i place in some other directory ( i.e. NetInv/
with NIpath = "java -
classpath .;...lib\\jaxb\\namespace.jar NetInv.com.ni.NI" )I get an error.
I think it has something to with the fact that part of
the path I specified is compressed in a .jar file
(everything except for NetInv/ is in .jar file). Does
anybody have a clue as to what's going on?

btw, error = "Exception in thread "main"
java.lang.NoClassDefFoundError:
NetInv/com/ni/NI "

also when executable is in the same folder as my program's
executable, it only works properly when I physically
double click on the executable that is generated, if i run
my executable from visual studio i get the same error. Why
does this happen, does it run the executable from some
other location??

Reply With Quote
  #2  
Old June 24th, 2003, 04:55 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,589 Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 26 m 52 sec
Reputation Power: 1001
I notice that you have the first argument of CreateProcess() as NULL. Have you tried calling CreateProcess like this instead:

createProcessStatus = CreateProcess("java", "-classpath .;...restofstuff...", NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);

You may need to set the first argument to "/path/to/java" instead of plain "java". Also, the lpCurrentDirectory parameter might need to be set. See http://msdn.microsoft.com/library/d...eateprocess.asp for more info about this.

Reply With Quote
  #3  
Old June 26th, 2003, 08:41 AM
lenochka lenochka is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 11 lenochka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question thank you, but it didnt work, any other ideas?

Thanks for your advice but it didnt work, I still think the problem has something to do with .jar compressed files. Even if I am right though, I do not know how to get around the problem. I tried several things:

char * NIpath = "java
-classpath
.;ni.jar;lib\\snmp4_13.jar;lib\\comm.jar;lib\\tablelayout.jar;lib\\jaxb\\jax-qname.jar;lib\\jaxb\\jaxb-api.jar;lib\\jaxb\\jaxb-libs.jar;lib\\jaxb\\jaxb-ri.jar;lib\\jaxb\\jaxb-xjc.jar;lib\\jaxb\\namespace.jar
com.ni.NetInventory";

char * NIpath2 = "java
-classpath
.;ni.jar;lib\\snmp4_13.jar;lib\\comm.jar;lib\\tablelayout.jar;lib\\jaxb\\jax-qname.jar;lib\\jaxb\\jaxb-api.jar;lib\\jaxb\\jaxb-libs.jar;lib\\jaxb\\jaxb-ri.jar;lib\\jaxb\\jaxb-xjc.jar;lib\\jaxb\\namespace.jar
NI.com.ni.NetInv";

char * NIcommand = "C:\\Program Files\\Java\\j2re1.4.1_02\\java
-classpath
.;ni.jar;lib\\snmp4_13.jar;lib\\comm.jar;lib\\tablelayout.jar;lib\\jaxb\\jax-qname.jar;lib\\jaxb\\jaxb-api.jar;lib\\jaxb\\jaxb-libs.jar;lib\\jaxb\\jaxb-ri.jar;lib\\jaxb\\jaxb-xjc.jar;lib\\jaxb\\namespace.jar";

char * NIcompath = "NI.com.ni.NetInven";

char * curWorkingDir = "C:\\RelCalc\\RelCalc\\Debug";

//attempt 1
createProcessStatus = CreateProcess(( "java", "-class path ..restof of stuff", NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, curWorkingDir, &si, &pi); //error code 2

//attempt 2
createProcessStatus = CreateProcess(( "C:\\Program Files\\..\\bin\\java", "-classpath ..restofstuff", NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, curWorkingDir, &si, &pi);
//error code 2

//attempt 3
createProcessStatus = CreateProcess(( NIcompath, NIcommand, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, curWorkingDir, &si, &pi);

//attempt 4
createProcessStatus = CreateProcess(( NIcommand, NIcompath, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, curWorkingDir, &si, &pi);

//still the only thing that work is
createProcessStatus = CreateProcess(( NULL, NIpath, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, curWorkingDir, &si, &pi);//when i double click on teh .exe generated, not when I run it from visual studio .. what is going on!?

Any additional advice will be greatly appreciated.
Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > error specifying path for CreateProcess


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT