Reply
 
Thread Tools Display Modes
  #1  
Old 08-10-2010, 09:30 AM
MarkKram MarkKram is offline
Junior Member
 
Join Date: Aug 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Java: Diablo JDK/JRE (libjvm.so)
Hello,

I have an installation of PCBSD 8.1. Through Software updates I also installed a Java JDK (JavaJDK 1.6.0.07.02_7).

This resulted in the following tree structure (I'm listing only the key parts):

/Programs/JavaJDK/
/Programs/JavaJDK/bin/javavm
/Programs/JavaJDK/diablo-jdk1.6.0/jre/lib/i386/client/libjvm.so
/Programs/JavaJDK/diablo-jdk1.6.0/jre/lib/i386/server/libjvm.so

I need to find (programmatically, C++) either of the libjvm.so, which I'm later loading. I need to know how to do it in a fast and robust way.

Following the symbolic links (starting with ./java) I can find /Programs/JavaJDK/bin/javavm, which later starts the appropriate java executable, I assume, either /Programs/JavaJDK/diablo-jdk1.6.0/bin/java or /Programs/JavaJDK/diablo-jdk1.6.0/jre/bin/java. By truncating /Programs/JavaJDK/bin/javavm I get /Programs/JavaJDK/. So now the task is to find the diablo jdk.

I need to know a few things regarding directory names (diablo-jdk1.6.0) and naming convention(s) of possible multiple installations (multiple versions of diablo jdk: diablo-jdk1.6.0, diablo-jdk1.6.1?, diablo-jdk1.7(.0)?, assuming they're subdirectories of /Programs/JavaJDK/). If they're not named in a "canonical" way, how to find the "default" one (or, alternatively, the latest one)? Listing directory entries and parsing the names seems a bit awkward to me. Isn't there a better way?

Regards,
Mark

P.S. I don't know if this is a question for PCBSD or FreeBSD, so feel free to redirect me there.
Reply With Quote
  #2  
Old 08-10-2010, 06:49 PM
Fatmice Fatmice is offline
Senior Member
 
Join Date: Feb 2008
Location: US
Posts: 888
Thanks: 0
Thanked 1 Time in 1 Post
Default
Neither, this is a programmer's question. You'd best ask java users =)

I'd imagine that java -v or something to the like will return the version number. You can then parse that with sed or awk or perl or whatever you like for the string with the version number.

As far as finding the path to libjvm.so that should be taken care of by PATH.

http://www.java.com/en/download/help/path.xml

There is another shell variable you can set and that is the CLASSPATH which allows you to set additional paths for SDK tools
and user classes.

http://download-llnw.oracle.com/java...classpath.html

As far as java goes, you can have multiple versions of it in one machine. It's a matter of the PATH.

Hopefully that answered your question?
__________________
|================================================= =====|
|Please search the forum prior to posting. Intellectual laziness is not nice. | (Does not apply to non-offenders =))
|================================================= =====|

Last edited by Fatmice; 08-10-2010 at 06:52 PM.
Reply With Quote
  #3  
Old 08-10-2010, 09:30 PM
MarkKram MarkKram is offline
Junior Member
 
Join Date: Aug 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Sadly, no.

Perhaps I haven't made myself clear enough. I don't need to do all of this (only) on my own system. I need to do it programmatically for a typical (as in third party) system on which my program will be running.

Since you mention the PATH, JAVA_HOME would be even better. But I cannot rely on it, since JAVA_HOME is usually not even set anymore. And neither is PATH (more precisely: it doesn't point to the libjvm.so).

I would ask "Java users" (perhaps you meant developers or distribution packagers) but I bet they would tell me that it was BSD's problem. Namely, Java installation usually follows a strict set of rules as far as directory structure is concerned. Not (PC)BSD's, though. That's why I'm asking here.

Again: I need to find libjvm.so. Either client or server one. I do this by climbing the symbolic link ladder until I get to the executable. The whole process is similar to this CLI series:

which java
/usr/local/bin/java

file /usr/local/bin/java
/usr/local/bin/java: symbolic link to `/usr/local/bin/javavm'

file /usr/local/bin/javavm
/usr/local/bin/javavm: symbolic link to `/Programs/JavaJDK/bin/javawm'

file /Programs/JavaJDK/bin/javawm
/Programs/JavaJDK/bin/javawm: POSIX shell script text executable

If one runs a similar process with Java installations on Linux or (Open)Solaris, once one gets to an executable, one can be pretty sure that libjvm.so (jvm.dll) can be found following a fixed path. Here's an example for my Linux box:

which java
/usr/bin/java

file /usr/bin/java
/usr/bin/java: symbolic link to `/etc/alternatives/java'

file /etc/alternatives/java
/etc/alternatives/java: symbolic link to `/usr/lib/jvm/java-6-sun/jre/bin/java'

file /usr/lib/jvm/java-6-sun/jre/bin/java
/usr/lib/jvm/java-6-sun/jre/bin/java: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.2.5, not stripped

From there to the libjvm.so I can follow ../lib/i386/client/ (or ../lib/i386/client/server/ if I want a server variant). There is no diablo-jdk1.6.0 in between. In fact, /Programs/JavaJDK/diablo-jdk1.6.0 is what should be a value of JAVA_HOME env variable and - by rights - symbolic links from the upper BSD example should point to /Programs/JavaJDK/diablo-jdk1.6.0/jre/bin/java instead of a mere /Programs/JavaJDK/bin/javawm. I understand that the script tries to cover all the eventuallities (including Linux compatibility layer if one installs a Linux variant of a JDK). That's why I'm asking how to go about it in a fast and robust way. Running "java -version", as you suggest, and then combining it with the diablo-jdk, isn't it. Firstly, because neither strings it returns (e.g. 1.6.0_07 nor 1.6.0_07-b02) directly corresponds to diablo-jdk1.6.0, and - more importantly - because I don't know how (where) future diablo releases/installations will be named (installed). Perhaps it will be DiAblo-java-7-[1.7.0-1.2.3_build-987], perhaps it won't. I don't know. You tell me.

Regards,
Mark
Reply With Quote
  #4  
Old 08-10-2010, 09:36 PM
Fatmice Fatmice is offline
Senior Member
 
Join Date: Feb 2008
Location: US
Posts: 888
Thanks: 0
Thanked 1 Time in 1 Post
Default
Let see now...there is already ld to take care of that.

If Java VM was installed properly on a system, then the runtime libjvm.so should be seen by ldconfig from the hint file.

So really, all you have to do is call ldd /path/to/executable and it should spit out all the paths ....

Am I missing something???
__________________
|================================================= =====|
|Please search the forum prior to posting. Intellectual laziness is not nice. | (Does not apply to non-offenders =))
|================================================= =====|
Reply With Quote
  #5  
Old 08-10-2010, 11:11 PM
MarkKram MarkKram is offline
Junior Member
 
Join Date: Aug 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Yes, you are. You're missing the whole thing. By a mile.

/Programs/JavaJDK/bin/javawm is a POSIX shell script text executable. One can't ldd nor objdump it.
Reply With Quote
  #6  
Old 08-11-2010, 01:06 PM
kmoore134's Avatar
kmoore134 kmoore134 is offline
Administrator
 
Join Date: May 2005
Location: Knoxville, TN
Posts: 2,568
Thanks: 0
Thanked 163 Times in 127 Posts
Default Java: Diablo JDK/JRE (libjvm.so)
Try this:

# cd /Programs/JavaJDK
# find . | grep libjvm.so

That should give you the location of the lib file, assuming it exists
__________________
----
Kris Moore
PC-BSD Founder
Reply With Quote
  #7  
Old 08-11-2010, 09:45 PM
MarkKram MarkKram is offline
Junior Member
 
Join Date: Aug 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Oh, man, this is getting ridiculous.

I need to do all this from within a C(++) program! Is this so hard to understand?

I don't need a (ba)sh, nor C(++) lesson. I just need to know the following:

1. Will he future releases/installations of diablo follow the same directory structure pattern as the current one (.../diablo-jdk1.6.0/...) or not?

2. Is there a better way to determine which one of the diablo-jdkx.x.x subdirectories is the current/latest installation, than the actuall reading of the directory entries and parsing of the diablo subdirectory names?

Regards,
Mark
Reply With Quote
  #8  
Old 08-11-2010, 10:07 PM
Fatmice Fatmice is offline
Senior Member
 
Join Date: Feb 2008
Location: US
Posts: 888
Thanks: 0
Thanked 1 Time in 1 Post
Default
1/ You should ask diablo maintainer for this question. It is likely that they follow a certain format for each release.

2/ No easy answer to this question. Why? Because multiple java version can coexist... The best way to know which is currently active is to just call java itself and ask it to spit out the version. You can then capture that information using C++ codes and then use that to find the path to libjvm.so.

Besides, since javavm is a script, you can parse it directly in C++ for needed information.
__________________
|================================================= =====|
|Please search the forum prior to posting. Intellectual laziness is not nice. | (Does not apply to non-offenders =))
|================================================= =====|

Last edited by Fatmice; 08-12-2010 at 03:40 PM.
Reply With Quote
  #9  
Old 08-12-2010, 11:49 AM
MarkKram MarkKram is offline
Junior Member
 
Join Date: Aug 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default
1. That was a first piece of (semi)usable info you gave me. Thank you very much. How do I get in touch with the maintainer, though?

2. That could be done, yes. But it would be rather cumbersome, if not slow (starting a new process and then parsing its output, which format is, mildly put, not very reliably defined).

BTW: javawm was a typo on my part. The correct name is javavm. Anyway, parsing it would be a PITA. I don't want to go into that much trouble. I'd rather leave BSD out of my supported systems (Linux, Solaris, BSD, Windows).

Regards,
Mark
Reply With Quote
  #10  
Old 08-12-2010, 03:45 PM
Fatmice Fatmice is offline
Senior Member
 
Join Date: Feb 2008
Location: US
Posts: 888
Thanks: 0
Thanked 1 Time in 1 Post
Default
Originally Posted by MarkKram View Post
1. That was a first piece of (semi)usable info you gave me. Thank you very much. How do I get in touch with the maintainer, though?
Look here under support section.

http://www.freebsdfoundation.org/downloads/java.shtml


Originally Posted by MarkKram View Post
2. That could be done, yes. But it would be rather cumbersome, if not slow (starting a new process and then parsing its output, which format is, mildly put, not very reliably defined).

BTW: javawm was a typo on my part. The correct name is javavm. Anyway, parsing it would be a PITA. I don't want to go into that much trouble. I'd rather leave BSD out of my supported systems (Linux, Solaris, BSD, Windows).

Regards,
Mark
Well, it is up to you as a developer to decide which platform you want to support. IMO, PITA shouldn't be a factor =)

Here is an interesting read.

http://lists.freebsd.org/pipermail/f...st/008196.html
__________________
|================================================= =====|
|Please search the forum prior to posting. Intellectual laziness is not nice. | (Does not apply to non-offenders =))
|================================================= =====|
Reply With Quote
Reply

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


All times are GMT. The time now is 03:35 PM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

Copyright 2005-2010, The PC-BSD Project. PC-BSD and the PC-BSD logo are registered trademarks of iXsystems.
All other content is freely available for sharing under the terms of the Creative Commons Attribution License.