• 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

how to invoke a java program using shellscript

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How can i exceute a java program using shellscript.
tried like :
#!bin/sh
path/to/java test.java


but its not invoking the program.

could you please suggest me on this?

Regards.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
don't you want the name of the class - not the name of the java file?

#!bin/sh
path/to/java test
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"java" is the interpreter, not the compiler. It takes a class name as parameter, not a source file.
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And it should be #!/bin/sh.
 
guestin loy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried by giving class name also. but it is still not invoking that.

#!/bin/sh
path/to/java test


its giving error as :
path/to/java: not found

could you suggest on this?
Regards.
 
Thomas Thevis
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If java is properly installed on your system, it should suffice to only type 'java'. You can check this by typing 'java -version'. If you receive some information about your JVM you're fine. Otherwise, check whether your 'path/to/java' is actaually a path to the java binary. If so, it usually looks something like 'path_to_java_install_dir/bin/java'.
[ October 15, 2008: Message edited by: Thomas Thevis ]
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forget about the shell script - what works on the command line? if it works on the command line, it should work in the script.
 
reply
    Bookmark Topic Watch Topic
  • New Topic