Operating System - Linux
1825677 Members
3724 Online
109686 Solutions
New Discussion

Java programs on HP-UX don't execute

 
eeriehunk
Occasional Contributor

Java programs on HP-UX don't execute

Hi,
I have a HP-UX 11i V2 and we installed Java1.5 on it.
I also set the CLASSPATH and the PATH variables as per the HP-UX documentation. Just to be sure I set both PATH and CLASSPATH as '/opt/java1.5/bin' and then I did an 'export PATH' and 'export CLASSPATH' as follows:
'PATH=$PATH:.:/opt/java1.5/bin:/op
t/java1.5/jre/lib:/opt/java1.5'
'CLASSPATH=.:/opt/java1.5/bin:/opt/java1.5:/opt/java1.5/jre/lib
export CLASSPATH'
I am unable to compile java code from my user home. It keeps saying "java.lang.Error: Properties init: Could not determine current working directory".
Then when I try to compile it from the java source (that is /opt/java1.5/bin/>javac helloworld.java -d /home/project/username) it creates a .class file with no compilation errors. But when I try to run this .class file (that is opt/java1.5/bin>java /home/project/username/helloworld) it gives me an error 'Exception in thread "main" java.lang.NoClassDefFoundError: /home/project/username/helloworld.
I checked this helloworld program on my Windows machine and it works fine.
Kindly reply with a soln. I would be glad to give more infomation if needed.
Thanks in advance.
4 REPLIES 4
Padma Asrani
Honored Contributor

Re: Java programs on HP-UX don't execute

Ben Dehner
Trusted Contributor

Re: Java programs on HP-UX don't execute

Well, you were reading the documentation, so that was your first mistake ...

First, for the CLASSPATH variable, I would set it to 'CLASSPATH=.'. CLASSPATH only pertains to the location of .class files, and the other stuff isn't needed. Java will always find the core system classes.

However, the compile error 'could not determine the current working directory' is not a problem with the classpath; it looks more like a problem with the shell environment. For some reason, it seems the process cannot determine what the current working directory (".") is or cannot read the directory. When you compile using an absolute path with the "-d" option, this is avoided, because it over-rides the CLASSPATH. Either something is wrong with the shell or something is funny about the directory permissions.

The run-time error is a bit different. The JRE will ONLY look at the CLASSPATH environment variable, and interprets the command line as the name of a Java class. In this case, it is looking for a class named "/home/project/username/helloworld", in the current CLASSPATH, which is different than looking for a file named "/home/project/username/helloworld.class".
Trust me, I know what I'm doing
Steven E. Protter
Exalted Contributor

Re: Java programs on HP-UX don't execute

Shalom,

What about JAVAPATH or JAVA_PATH

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
eeriehunk
Occasional Contributor

Re: Java programs on HP-UX don't execute

Assuming this problem pertains more to HPUX environment, I posted the above issue there and it was resolved. It was the problem with the class path. Thank you for your response.
Regards,
eeriehunk