Why does my java program only run with -debug in my parameters.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   S_Barnes
Posted On:   Friday, August 5, 2005 04:58 AM

Hello, I am trying to run a java program on the UNIX shell of our Z/OS mainframe box and I am having trouble with my classpath. I am running the java HelloWorld command within the directory that the class file is and I am getting an error message saying that it cannot find class HelloWorld. I have tried the java command with the following variations. /u/yzilg1 is the directory HelloWorld is in. java –classpath . HelloWorld java –classpath “.” HelloWorld java –classpath /u/yzilg1 HelloWorld java –classpath “/u/yzilg1” HelloWorld java –classpath u/yzilg1 HelloWorld java –classpath “u/yzilg1” HelloWorld java –classpath /u/yzilg1/ HelloWorld ja   More>>

Hello,


I am trying to run a java program on the UNIX shell of our Z/OS mainframe box and I am having trouble with my classpath.



I am running the java HelloWorld command within the directory that the class file is and I am getting an error message saying that it cannot find class HelloWorld. I have tried the java command with the following variations. /u/yzilg1 is the directory HelloWorld is in.



java –classpath . HelloWorld
java –classpath “.” HelloWorld
java –classpath /u/yzilg1 HelloWorld
java –classpath “/u/yzilg1” HelloWorld
java –classpath u/yzilg1 HelloWorld
java –classpath “u/yzilg1” HelloWorld
java –classpath /u/yzilg1/ HelloWorld
java –classpath “/u/yzilg1/” HelloWorld
java HelloWorld



I have also set the CLASSPATH in my .profile file to /u/yzilg1 and when I type echo £CLASSPATH it does show the one I put in my .profile. None of these work.



However when I tried java –debug HelloWorld without any classpath details the program runs and displays the message on the screen.



It is the same for jar files that I have copied across from my PC. They only run when –debug is added to the java command.



Why would –debug make the programs run and how can I make it work without it?



Any ideas would be gratefully received.

Thanks.

   <<Less

Re: Why does my java program only run with -debug in my parameters.

Posted By:   Stephen_Ostermiller  
Posted On:   Friday, August 5, 2005 05:19 AM

It is the same for jar files that I have copied across from my PC. They only run when –debug is added to the java command.


If HelloWorld.class is in a jar file, then the class path needs to be the jar file to get it to run:

java -classpath /u/jilg1/helloworld.jar HelloWorld


Alternately, you could add a manifest file to the jar that has the name of the class with the main method. Then you could just run it with:

java -jar /u/jilg1/helloworld.jar

About | Sitemap | Contact