Java Not working in AIX 6.1

I recently installed git in my AIX Server and git works fine.

But java is not working now.

If i do a java --version I'm getting the foll output.

admin:stud:/webapps/WEB-INF/classes> java -version
exec(): 0509-036 Cannot load program java because of the following errors:
        0509-150   Dependent module /opt/freeware/lib/libiconv.a(shr4_64.o) could not be loaded.
        0509-152   Member shr4_64.o is not found in archive

Open in new window

How can I fix this.

I installed GIT on my dev machine and this problem of the libiconv.a problem is occuring not containing shr4_64.o but in my qa machine libiconv.a was not even installed which has the same version of java installed as my dev machine.

Previouly the below java version was installed.

admin:stud:/demo> java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build pap64dev-20080315 (SR7))
IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 AIX ppc64-64 j9vmap6423-20080315 (JIT enabled)
J9VM - 20080314_17962_BHdSMr
JIT  - 20080130_0718ifx2_r8
GC   - 200802_08)
JCL  - 20080314

Open in new window


This is a output from my QA server which has the same java installed as the dev machine which is currently giving me the error.

What can i do to fix this.

Please help..
gaugetaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:
Do you have a LIBPATH which points to /opt/freeware/lib?

echo $LIBPATH

The original (and working) version of libiconv.a is in /usr/lib, so if there is a wrong LIBPATH unset it with

unset LIBPATH

and retry.

If the above doesn't help please post the output of

which java

and

ldd $(which java)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gaugetaAuthor Commented:
@woolmilkporc:Thanks for replying.

The output of echo $LIBPATH

admin:stud:/demo> echo $LIBPATH
/dun/pvcspkg/pvcs81_aix/vm/common/lib/aix:/dun/pvcspkg/pvcs81_aix/vm/common/lib/aix:/local/lib:/stud_devel/lib:/sybase/ASE-15_0/lib:/sybase/OCS-15_0/lib:/sybase/OCS-15_0/lib3p:/sybase/OCS-15_0/lib3p64:/opt/freeware/lib:/usr/lib:/usr/lib/secure:/mftps/libs:/usr/lib:/usr/lib/secure

Open in new window


The output of which java
admin:stud:/demo> which java
/usr/java5_64/bin/java

Open in new window


ldd $(which java) did not return anythin saying its an "Illegal variable name."
woolmilkporcCommented:
As you can see, you have /opt/freeware/lib before /usr/lib in your LIBPATH, and this is the reason why your 64bit java tries to use the 32-bit only libiconv from there, which can't work.

So either change the sequence of path elements in your LIBPATH so that /usr/lib comes before /opt/freeware/lib or uninstall the freeware version of libiconv if you don't need it for other applications (rpm -e ...)

Which shell do you use? With ksh which is standard on AIX "ldd $(which java)" should work just fine, and also with bash. With csh try "ldd `which java` ".
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

gaugetaAuthor Commented:
I need the libiconv gor GIT since its a dependency for git.

How can I reset my LIBPATHvariable so that /usr/lib comes before  /opt/freeware/lib.
woolmilkporcCommented:
Find out where it's being set.

This could be in /etc/environment, /etc/profile, your ~/.login, ~/.cshrc or ~/.tcshrc files.

Again, which shell do you use? tcsh?
gaugetaAuthor Commented:
Yes its set in .tcshrc since I use a TC shell.

I reset the LIBPATH variable by putting /usr/lib before /opt/freeware/lib and then when I try checking my GIT and Java versions i get the foll output.

admin:stud:/demo> java -version
exec(): 0509-036 Cannot load program java because of the following errors:
        0509-150   Dependent module /opt/freeware/lib/libiconv.a(shr4_64.o) could not be loaded.
        0509-152   Member shr4_64.o is not found in archive


admin:stud:/demo> git --version
exec(): 0509-036 Cannot load program git because of the following errors:
        0509-150   Dependent module /usr/lib/libiconv.a(libiconv.so.2) could not be loaded.
        0509-152   Member libiconv.so.2 is not found in archive

Open in new window


And later when I put /opt/freeware/lib before /usr/lib my Git works but java still shows the same error.
woolmilkporcCommented:
At least java still has the wrong LIBPATH. Seems you didn't change it in the right place.

Can't you just try to "unset" the LIBPATH completely?

Most executables have  compiled-in paths.
gaugetaAuthor Commented:
How can I unset it.Do you want me to delete all contents of .tcshrc file?
woolmilkporcCommented:
No.

Once logged in to your shell issue

unset LIBPATH

and retry. Don't logout/login inbetween. See my very first comment, btw.
gaugetaAuthor Commented:
I removed the /opt/freeware/lib from my LIBPATH and my java works fine.

But my git is not working now.


admin:STUD:/demo> git --version
exec(): 0509-036 Cannot load program git because of the following errors:
        0509-150   Dependent module /usr/lib/libiconv.a(libiconv.so.2) could not be loaded.
        0509-152   Member libiconv.so.2 is not found in archive

Open in new window


If I try to put /opt/freeware/lib after /usr/lib both java and git does not work.

If I put /opt/freeware/lib before /usr/lib git works but java dosent.

And for java to work I have to completely remove /opt/freeware/lib from my LIBPATH variable.

How can I make both work.
woolmilkporcCommented:
unset LIBPATH

?
gaugetaAuthor Commented:
I tried both
1)unset LIBPATH
2)unset $LIBPATH

both have no output and after trying out these commands if i try : $echo $LIBPATH
I get the entire same sontents.

And still java does not work.
woolmilkporcCommented:
Seems it's tcsh.

set LIBPATH=
gaugetaAuthor Commented:
I tried set LIBPATH=

And when I tried echo $LIBPATH nothing returned.
And GIT worked and Java did not.

And I started new terminal.
The  LIBPATH variable was set with contents I have in my .tcshrc file.
And now Git works and Java does not.

But currently in .tcshrc file /opt/freeware/lib is before /usr/lib.
So In what order do I nedd to arrange for bith to work.
Now I can make only Java or Git to work but not both.
woolmilkporcCommented:
After

set LIBPATH=

java should have worked!

Which error message did you get?

It could be that under tcsh you must run

unsetenv LIBPATH

or, if this doesn't work

setenv LIBPATH

Don't start a new terminal inbetween!
gaugetaAuthor Commented:
After
 set LIBPATH=

Java did not work.And I got the error message.
admin:stud:/demo> java -version
exec(): 0509-036 Cannot load program java because of the following errors:
        0509-150   Dependent module /opt/freeware/lib/libiconv.a(shr4_64.o) coul                                             d not be loaded.
        0509-152   Member shr4_64.o is not found in archive

Open in new window


After unsetenv LIBPATH

Java works but Git does not work.

And if I start a parallel terminal after the above steps: Git works and Java does not.
woolmilkporcCommented:
unsetenv is only effective in your current shell. Starting a new shell will reinitialize the old environment by runnning .tcshrc.

Well, I fear you will have to create a script either for java or git, to get a valid LIBPATH setting.

For java a script called "myjava" could look like this:

#!/usr/bin/tcsh
unsetenv LIBPATH
java "$*"

Put "myjava" in a location available to all users, e.g. /usr/local/bin, then issue "chmod +x /usr/local/bin/myjava"

/usr/local/bin/myjava -version

should work now

You can additionally set in .tcsh

alias java "/usr/local/bin/myjava"

java -version

will also work now (after starting a new shell)
gaugetaAuthor Commented:
Yes that  worked. at the first go

Now when I start a new terminal and I have set the alias before opening terminal.

And If I give java -version the control goes to next line and never and after a very long time returns

admin:stud:/demo> java -version
Word too long.

Open in new window

.

Aliasing is not working.
If I remove the alias and give the /full/path/of/myjava -version it works.

What's wrong here?

What about javac ?
Should I create a script for that too?
woolmilkporcCommented:
What do you mean with " I have set the alias before opening terminal"?

In order to have the alias immediately available after starting the terminal you must set it in .tcshrc. Did you do that?

If so, this must be  a tcsh issue.

I'd suggest changing the script to use ksh:

#!/usr/bin/ksh
unset LIBPATH
java "$@"

Please note that it's now "unset" instead of "unsetenv", and "$@" instead of "$*".

And yes, you must do the same for javac.
gaugetaAuthor Commented:
@woolmilkporc: Thanks a lot.Worked perfectly.

What is the $@ in the java "$@" that I added in the script.

What's the best source to refer/study unix/linux administration.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.