• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How should I do that by the way??
 
Ivan Jozsef Balazs
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That should be:
 
Ivan Jozsef Balazs
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
 
Balkishore pandey
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot mate. Using "/usr/local/bin/node " solved the issue.
 
Greenhorn
Posts: 15
Mac Objective C Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic