LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-13-2005, 04:32 AM   #1
borgy_t
LQ Newbie
 
Registered: Feb 2005
Location: philippines
Distribution: red hat 9
Posts: 26

Rep: Reputation: 15
Java: runtime problems


here is my code:
Code:
	try {
		Runtime r = Runtime.getRuntime();
		Process p = r.exec ( "\\\\192.168.185.232" );
	}
	catch (Exception e) {
		e.printStackTrace();
	}
when i type "\\192.168.185.232" into the run console of windows, i can access the samba server. but when i execute this code in Java i get an error which says:

java.io.IOException: CreateProcess: \\192.168.185.232 error=123
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)


the IP Address is the address of the samba server. alternatively, i can type "\\linuxpdc" in the windows run console ("\\\\linuxpdc" in java) to access the server. "\\\\linuxpdc" gives me the same error as "\\\\192.168.185.232".

why is this so? what should be my argument inside r.exec (String cmd) be to make it work?

btw, the application running this code is in windows. when i replace "\\\\192.18.185.232" with "explorer" or "notepad", etc it works.

thanks in advance!

Last edited by borgy_t; 04-13-2005 at 04:34 AM.
 
Old 04-13-2005, 07:46 AM   #2
ahwkong
Member
 
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282

Rep: Reputation: 30
"\\\\192.168.185.232" is not a command to java.

It is not a command to a DOS prompt in Windows either. Try "\\\\192.168.185.232" and DOS prompt cannot understand it.

What you see happening in Window is by design. It is a feature in Window's explorer. MS integrates IE into explorer such that explorer understand the "\\" syntax. It is similar to the way MS Window associates an file extension with a particular application. MS try to make it easier for you by guessing which application should be invoked for the particular file or url.

So back to java. exec() is more akin to execution of a program via a shell. It will not do the guess work, so you have to specify it.
 
Old 04-13-2005, 09:39 AM   #3
borgy_t
LQ Newbie
 
Registered: Feb 2005
Location: philippines
Distribution: red hat 9
Posts: 26

Original Poster
Rep: Reputation: 15
i think i found the answer. i need JCIFS to enable my app to connect to the samba server. don't know ANYTHING about it though... help please!

Last edited by borgy_t; 04-13-2005 at 09:42 AM.
 
Old 04-13-2005, 09:47 AM   #4
ahwkong
Member
 
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282

Rep: Reputation: 30
If you use this lib to access the samba share drive, you would not be using exec().

If you use this lib, it means you are going to access the share via programmatical means. e.g. create a smbSession object first before list the content in the share.

I hope you understand the difference between this appoarch and exec() in your original post.
 
Old 04-13-2005, 09:33 PM   #5
borgy_t
LQ Newbie
 
Registered: Feb 2005
Location: philippines
Distribution: red hat 9
Posts: 26

Original Poster
Rep: Reputation: 15
yes yes, i understand i won't be using exec() to access the server. i will have to familiarize myself with JCIFS but first, i would have to find an online guide or tutorial. any suggestions as where to find them? googling hasn't given me very helpful results.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Programming: Java Runtime Environment not found when trying to compile murbz Linux - Software 2 03-26-2009 04:04 AM
LimeWire install - problems with Java Runtime Enviroment Par4n0iA Linux - Software 15 03-15-2007 07:22 PM
Getting Java Runtime To Run tsuehpsyde Fedora 2 05-03-2004 01:54 AM
java runtime shariqali Linux - Software 7 09-23-2003 11:08 PM
Java Runtime Env. Ratclaws Linux - Software 1 07-03-2002 08:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration