This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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: 1043
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: 75637
354
  • 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: 1043
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: 1043
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: 1043
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: 1043
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.
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic