Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.io.IOException: error=2, No such file or directory in mac OSX  RSS feed

 
Balkishore pandey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to run a node.js script from java. And the following is my source code:



In doing so, i get an error java.io.IOException: error=2, No such file or directory

What am I doing wrong here?

Any help?
 
Ivan Jozsef Balazs
Rancher
Posts: 992
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that you want to run a script, which is not runnable alone, but only in conjunction with the shell executable.

The shell program could be bash or whatnot - I do not know mac OSX.
 
Campbell Ritchie
Sheriff
Posts: 53747
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you any idea which file doesn’t exist?

I shall move this thread, because it is too difficult for “beginning”.
 
Balkishore pandey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thanks a ton for replying.

The file exists. When I type the same on terminal, the file executes.
 
Ivan Jozsef Balazs
Rancher
Posts: 992
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you type in on the terminal in order to run it?

What is the file? A script or an executable? I maintain my first guess.
 
Balkishore pandey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It is a script. A javascript file. Inorder to run it in terminal. I usually goto to the folder where the file exist and type



node is also set as environment variable.

Thanks for the help.
 
Ivan Jozsef Balazs
Rancher
Posts: 992
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see.

You could try "node" with its full path name.
 
Balkishore pandey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How should I do that by the way??
 
Ivan Jozsef Balazs
Rancher
Posts: 992
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume "node" is a program picked by the command prompt. It must reside somewhere like /opt/where/ever/utils/node, so you can use the full path name.

Just a wild guess though.

Under Linux I'd use "type" or "which" to locate "node".

oracle@izsak:/tmp> type bash
bash is /bin/bash

oracle@izsak:/tmp> which bash
/bin/bash
 
Balkishore pandey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Node resides in /usr/local/bin/node, but what will I do with it??

when I type

master1:~ kishore$ node /Users/kishore/Desktop/serialport/listport.js

on my terminal, the script runs.

So I decided to copy this file where my netbeans project folder resides, (i.e) my user directory and did something like:

String directory = System.getProperty("user.dir" + "/listport.js");
System.out.println(directory);

And got the output as null. So my concern is how can I store the path in a string along with the filename?
 
Tony Docherty
Bartender
Posts: 3200
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

That should be:
 
Ivan Jozsef Balazs
Rancher
Posts: 992
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Balkishore pandey wrote:Hi,
Node resides in /usr/local/bin/node, but what will I do with it??


Use "/usr/local/bin/node" instead of plain "node".
 
Balkishore pandey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.
 
Balkishore pandey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot mate. Using "/usr/local/bin/node " solved the issue.
 
Ben Alex Barreto
Greenhorn
Posts: 15
Java Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know this is probably just test code, but nonetheless, let me tell ya :P Adding a Throws declaration to the main method is terrible idea, because if it does throw an IO exception, it will be sent to the JVM itself, and you will never be able to handle it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!