DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD Packages and Ports

OpenBSD Packages and Ports Installation and upgrading of packages and ports on OpenBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 29th July 2008
incripshin incripshin is offline
New User
 
Join Date: Jul 2008
Posts: 5
Default Problems running jdk-1.7

I just installed jdk-1.7, but it doesn't quite work. I have /usr/local/jdk-1.7.0/bin in my PATH. When I run java or javac, I get this:

Code:
$ javac
Error: could not find libjava.so
Error: Could not find Java SE Runtime Environment.
If I give the full path to the binary, it runs fine. libjava.so is located in /usr/local/jdk-1.7.0/jre/lib/i386/libjava.so. I tried adding it to the arguments sent to ldconfig, but all that happens is this:

Code:
$ sudo ldconfig /usr/X11R6/lib /usr/local/lib /usr/local/jdk-1.7.0/jre/lib/i386
$ ldconfig -r | grep jdk
        search directories: /usr/lib:/usr/X11R6/lib:/usr/local/lib:/usr/local/jdk-1.7.0/jre/lib/i386
Anybody have better luck than me?

Last edited by incripshin; 29th July 2008 at 04:46 AM. Reason: /* way better title */
Reply With Quote
  #2   (View Single Post)  
Old 29th July 2008
incripshin incripshin is offline
New User
 
Join Date: Jul 2008
Posts: 5
Default

Also I'm running -current, and I really wish I gave this thread a better title. ... TITLE FIXED!

Last edited by incripshin; 29th July 2008 at 04:49 AM. Reason: /* totally figured out how to change the title -> awesome */
Reply With Quote
  #3   (View Single Post)  
Old 29th July 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by incripshin View Post
If I give the full path to the binary, it runs fine.
I don't run 1.7, but creating symlinks in 1.6 has worked for me:
Code:
# ln -sf /usr/local/jdk-1.6.0/bin/java /usr/local/bin/java
# ln -sf /usr/local/jdk-1.6.0/bin/javac /usr/local/bin/javac
Reply With Quote
  #4   (View Single Post)  
Old 29th July 2008
incripshin incripshin is offline
New User
 
Join Date: Jul 2008
Posts: 5
Default

Quote:
Originally Posted by ocicat View Post
I don't run 1.7, but creating symlinks in 1.6 has worked for me:
Code:
# ln -sf /usr/local/jdk-1.6.0/bin/java /usr/local/bin/java
# ln -sf /usr/local/jdk-1.6.0/bin/javac /usr/local/bin/javac
No dice. 1.5 and 1.6 behave nicely: when I have it in my PATH, it works fine. Also, this works regardless of PATH:

Code:
$ cd /usr/local/jdk-1.7.0/bin
$ ./java
[reams of output]
$ cd .. ; bin/java
[same]
$ cd .. ; jdk-1.7.0/bin/java
[same]
So, it seems like Java is finding the libraries by using getcwd() and argv[0]. This is clearly a horrible idea since it makes working with PATH impossible. I don't know how java 1.5 and 1.6 found the libraries, but it was definitely a different method.

The only solution besides changing the source code is messing with the linker. Currently, ldconfig does not see any of the libraries in /usr/local/jdk-1.7.0/jre/lib/i386 and I can't figure out why.

I also tried setting JAVA_HOME and JDK_HOME to /usr/local/jdk-1.7.0.

Last edited by incripshin; 29th July 2008 at 07:48 AM. Reason: /* extra note */
Reply With Quote
  #5   (View Single Post)  
Old 29th July 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by incripshin View Post
I don't know how java 1.5 and 1.6 found the libraries, but it was definitely a different method.
My suggestion would be to contact the port maintainer & ask him. The appropriate email address can be found by issuing the following command:

$ cd /usr/ports ; make search key=jdk

Once you have resolution, it would be great if you would report here what was both the issue & solution.
Reply With Quote
  #6   (View Single Post)  
Old 1st August 2008
incripshin incripshin is offline
New User
 
Join Date: Jul 2008
Posts: 5
Default resolved, kind of

So it was an issue with dladdr(), bug compatible with Solaris by the looks of it. Changing one line of the source code fixes it. The maintainer probably won't commit the change because of a ports soft-lock for 4.4, so in the meantime, you can either apply it yourself or make some shell scripts to do the work for you:

Code:
--- patch-jdk_src_solaris_bin_java_md_c.old	2008-07-31 20:34:09.000000000 -0500
+++ patch-jdk_src_solaris_bin_java_md_c	2008-07-31 20:34:19.000000000 -0500
@@ -41,15 +41,6 @@
        /*
         * On linux, if a binary is running as sgid or suid, glibc sets
         * LD_LIBRARY_PATH to the empty string for security purposes.  (In
-@@ -841,7 +851,7 @@ static const char*
- SetExecname(char **argv)
- {
-     char* exec_path = NULL;
--#if defined(__solaris__)
-+#if defined(__solaris__) || defined(_ALLBSD_SOURCE)
-     {
-         Dl_info dlinfo;
-         int (*fptr)();
 @@ -1209,6 +1219,20 @@ UnsetEnv(char *name)
      return(borrowed_unsetenv(name));
  }
Alternative scripts to make at /usr/local/bin/java, /usr/local/bin/javac, etc. (notice the backticks):
Code:
#!/bin/sh
exec /usr/local/jdk-1.7.0/bin/`basename $0` "$@"
Reply With Quote
  #7   (View Single Post)  
Old 1st August 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by incripshin View Post
So it was an issue with dladdr(), bug compatible with Solaris by the looks of it. Changing one line of the source code fixes it. The maintainer probably won't commit the change because of a ports soft-lock for 4.4, so in the meantime, you can either apply it yourself or make some shell scripts to do the work for you:
Thanks for sharing what you found out!
Reply With Quote
  #8   (View Single Post)  
Old 1st August 2008
incripshin incripshin is offline
New User
 
Join Date: Jul 2008
Posts: 5
Default

The change will make it in despite the lock, so it appears we will all get a working JDK/JRE in the next OpenBSD release without having to accept Sun's license agreements and spend half a day compiling.
Reply With Quote
  #9   (View Single Post)  
Old 9th August 2008
schrodinger's Avatar
schrodinger schrodinger is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Ireland
Posts: 69
Default

just installed 4.3 onto my new laptop and i was about to start the ports build of devel/jdk/1.6 do I have to patch with the diff posted above??
__________________
It was a new day yesterday, but it's an old day now.
Reply With Quote
Old 9th August 2008
ocicat ocicat is offline
Administrator
 
Join Date: Apr 2008
Posts: 3,318
Default

Quote:
Originally Posted by schrodinger View Post
...do I have to patch with the diff posted above??
No, the above discussion is specific to the JDK 1.7 port only for current users who are not running what is presntly in the -current ports tree. I built -current as of yesterday & can say firsthand that the above fix was been checked in for JDK 1.7.

Last edited by ocicat; 9th August 2008 at 05:01 PM.
Reply With Quote
Old 10th August 2008
schrodinger's Avatar
schrodinger schrodinger is offline
Fdisk Soldier
 
Join Date: May 2008
Location: Ireland
Posts: 69
Default

woops, you're right this was 1.7 specific. thanks for the reply though.
__________________
It was a new day yesterday, but it's an old day now.
Reply With Quote
Reply

Tags
java, jdk

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Running as a WPA-RADIUS AP? Sunnz OpenBSD Security 7 23rd September 2009 02:09 AM
Problem getting php running badguy OpenBSD General 7 22nd July 2009 03:34 PM
Running your own web server JMJ_coder General software and network 28 13th February 2009 01:15 AM
compiling and running perl/tk bsdnewbie999 Programming 4 10th August 2008 10:22 AM
Cron running but not working stukov Other BSD and UNIX/UNIX-like 26 24th July 2008 01:17 PM


All times are GMT. The time now is 09:34 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick