Write a java program that contains a shell script
hey folks...
request your help...
Write a java program that contains a shell script which will point to the local directory (current working directory ) and a create a folder there.
When I run the java program using the IDE, it should create a folder in my current working directory,,,
but again the java code must have the shell script to do this task..
please help...
Re: Write a java program that contains a shell script
http://stackoverflow.com/questions/5...from-java-code
But not generally a good idea because it ties your (portable) java application to unix/linux systems.
Alternatively, use the API functions
http://stackoverflow.com/questions/4...folder-in-java
Re: Write a java program that contains a shell script
Yea.. Its true that its not a good idea...
but it was an assigned task to me... so I have to do it :)
Thanks Alex for your response..
But i tried the code mentioned on
http://stackoverflow.com/questions/5...from-java-code
Doesnt seem to work... :(
Re: Write a java program that contains a shell script
Was there an error? Did the program print a stack trace? Does the shell script work when you invoke it by hand rather than from the java program?
Re: Write a java program that contains a shell script
yea.. it says it cant recognise /bin/ksh .
its obvious because I cant execute a shell command from windows...
could someone please post in a complete working program...
Re: Write a java program that contains a shell script
Quote:
Originally Posted by
jemvision
yea.. it says it cant recognise /bin/ksh .
its obvious because I cant execute a shell command from windows...
If you are running your program in Windows you need to use cmd for the shell instead of ksh. You also need to pass /C as an option to cmd so it runs the command (ie your shell script) and terminates, otherwise it will keep running, waiting for more commands (as when you open a DOS window).
Quote:
Originally Posted by
jemvision
could someone please post in a complete working program...
Nope, that's your homework for you to do. It was given to you so you can practice what you have been taught. If we give you a complete working program it would be like cheating and you would learn nothing. We can help you through any issues you may found, but it's going to be better for you to do your homework yourself.