File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Java Class Won't Execute At Command Line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Class Won Watch "Java Class Won New topic

Java Class Won't Execute At Command Line

Preston Thornton
Ranch Hand

Joined: Jun 24, 2008
Posts: 80
Hi, everyone,

I am working to sew together a two java programs, and I need to have them execute at the command (DOS prompt, for example) so that I can integrate it into HP Openview Operations as a Monitor program. I was able to test and run the program in Eclipse fine, and not at the command prompt. Here is the code and class files.

Class Files:
03/11/2012 11:30 AM 1,493 RuntimeExec$StreamWrapper.class
03/11/2012 11:30 AM 2,124 RuntimeExec.class

Windows CMD prompt:

I know its something I am over looking.
Thanks for your help in advance.

L Thornton
Tina Smith
Ranch Hand

Joined: Jul 21, 2011
Posts: 208

The full package name should be included in the name of the class where main() is located.
In your case you want to run "java Cmdline.RuntimeExec"

You may also want to consider adding java to your PATH environment variable, and not capitalizing any part of your package name.

Everything is theoretically impossible, until it is done. ~Robert A. Heinlein
Preston Thornton
Ranch Hand

Joined: Jun 24, 2008
Posts: 80
Thanks! I will make the adjustment and give it a try.

L Thornton
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

i dont use package statements much but what i remember is you have to cd to the folder one up from the package folder.
for example if the files are in myStuff\cmdLine, you need to cd to myStuff then type java cmdLine/RuntimeExec

Visit my download page
Rob Spoor

Joined: Oct 27, 2005
Posts: 20271

Randall Twede wrote:type java cmdLine/RuntimeExec

java cmdLine.RuntimeExec of course.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Java Class Won't Execute At Command Line
It's not a secret anymore!