Scripting Help needed for Install Oracle Java

After banging my head against this specific issue for nearly a day, I’m hoping other eyes can see what I can’t seem to see.
**
Original Documentation**
http://en.opensuse.org/SDB:Installing_Java

Issue:
The original documentation takes a lot of time to implement. My original install was done by modifying and pasting into an admin console.
After facing having to do all again in another machine, I decided I wanted to script the hundreds of commands in the original documentation, hopefully into 6 individual scripts, more or less

Scripts can be downloaded from here
Simply clone my github repo (or fork if you wish), the following command downloads everything to your local machine

git clone https://github.com/putztzu/openSUSE_Oracle_Java_Install.git

For Alpha Testing (recommend in a virtual Guest but it’s up to you)
Requirements (for now)
64-bit openSUSE (13.1 preferred, but likely works in any version of x64 openSUSE)

Basic changes and description from the original documentation:
The scripts should be OK to run from anywhere, there is no need to run from any speciic directory.
The scripts should be run from a root console instead of the sudo used in the original documentation.
The original documentation is based on the TAR but there are good reasons to use the RPM instead so that is what I’m basing on.
I’ve programmatically accomplished some steps which in the original documentation was done with individual commands, in particular compressing the MAN pages and creating symlinks from the Oracle source files to the /usr/lib64 directory which does a complete job. The original method was not only time-consuming it was incomplete (maybe some files were added after the openSUSE documentation was created

Basic steps:
Download current Oracle Java RPM from the Oracle website.

At the time of tis writing this is jdk-7.0_51 and the scripts reference specifically this.
Install the Oracle RPM

zypper in jdk-7u51-linux-x64.rpm

Run the scripts in a root console.

As described in the README, the first 5 scripts should work just fine. So the main parts of Oracle Java can be successfully configured in update-alternatives at present. Maybe even web browser support (I haven;'t tested but probably is OK).
The PROBLEM, script 6
But, I’m having a bear of an issue getting the sixth script to run. I’ve posted the two versions of the script I’ve tried to create… one based on script 4 which runs successfully and the other based on the formatted command as described in the original documentation.
I recommend running each in your own environment for testing, they each attempt to install javac into update-alternatives but will fail without leaving anything behind.

Of course, the results will be offered to the original documentation or if rejected posted as an alternative approach.

Comments/corrections can be posted here as well as in the github repository “issues”

TIA,
TSU

Hi, this is probably not helpful, but there seems to be a backslash character ("") in script 6 - is this intentional? HTH Lenwolf

All questions are welcomed.

Yes, the backslashes in one of the scripts are intentional. In that script (the formatted code) which is based on the original documentation, a backslash is at the end of every line. I removed them when I created the modified script when removing the formatting, putting the entire code into one single line.

The following is an excerpt copied directly from the original documentation (not my creation)

sudo /usr/sbin/update-alternatives --install /usr/bin/javac javac /usr/lib64/jdk_Oracle/bin/javac 3 \
--slave /usr/bin/appletviewer appletviewer /usr/lib64/jdk_Oracle/bin/appletviewer \
--slave /usr/share/man/man1/appletviewer.1.gz appletviewer.1.gz /usr/lib64/jdk_Oracle/man/man1/appletviewer.1.gz \
--slave /usr/bin/apt apt /usr/lib64/jdk_Oracle/bin/apt \
--slave /usr/share/man/man1/apt.1.gz apt.1.gz /usr/lib64/jdk_Oracle/man/man1/apt.1.gz \

TSU

Am coming to the conclusion that the source being used is just flawed.

Am going back to another source I know really works.
http://en.opensuse.org/SDB:Installing_Java#Adding_Java_Control_Panel_.28JRE.29

TSU

Didn’t notice I just reposted the same link for both working and non-working source.

I <know> the original source I was using was in some kind of full-blown online editor but my browser history doesn’t have it. Must be some kind of re-direct that existed last week but doesn’t now.

So, it looks like I’m back to having to figure out the problems with the sixth script.

Brief description of errors which I encourage anyone to take a look at…

  • The script that implements as a single line command, for some reason wsgen kicks this error successfully parsing approx 90% of the script. Since the format for the line that creates the wsgen option is identical to everything before it, it’s a mystery to me why all of a sudden there should be a problem there.
# ./6.Install_javac_into_update-alternatives.sh 
update-alternatives: error: unknown argument `wsgen'

The script that attempts to simply copy the document code just won’t run. Interestingly, if you look at the SDB history there probably is some issue about using the format and those backslashes, you can see changes and disagreement whether the code is correct, but no descriptive reasons.

TSU

Minor update –

I strongly suspect the reason why the single line command script is failing is because of the very long list of arguments, despite the error returned is not the standard error. Instead, I suspect the argument is not just being read into the command.

Reading up a bit, it seems that I did not see this error before is because as I described earlier I simply copied the code into a console, and apparently although that method is not supposed to be subject to a mas length command, reading a file (ie using a script) is. (BTW - Copying into a console still required splitting into 2 commands, possibly due to a buffer size but is different than the max length).

So, I’ve been testing a few methods which are supposed to change the max length but so far am SOL. I don’t understand the examples or they just won’t work. I also would prefer a temporary setting over a permanent setting if the setting likely re-allocates resources since this is a fairly unusual scenario.

TSU

Figured out the problem and now all files need to be tested! If you have any VMs or virtualized Guests you’d like to try the Oracle Java JDK, pls try my scripts which should save lots of time

Files are at
https://github.com/putztzu/openSUSE_Oracle_Java_Install

You can get the scripts for both 32bit and 64bit by simply cloning the repository to your local drive

git clone https://github.com/putztzu/openSUSE_Oracle_Java_Install.git

Thx!

Figured out what the problem was.
The problem wasn’t exactly what the error suggested but in the code preceding the reported error.

Also determined…
Bash command length wasn’t an issue in this case
An “update-alternatives” command can be executed more than once with different arguments. If the main app and/or group already exists, then any new arguments are added to the existing, so this is an easy way to overcome any max length or buffer restrictions.

So,
The new scripts for both x64 and x86 are finished and AFAIK should work fine to install the JDK completely into any 32bit or 64bit openSUSE no matter the version. After the Oracle JDK is installed, if no other Java is also installed, Java support should automatically be available for the JRE, Java Compiler and Web Browser plugin support. If another Java is installed (eg openJDK), then the three update-alternatives commands to select what you want to implement are in the original documentation (and I can repeat if necessary). In fact, this is one big reason why I diverged from the original documentation which removed openJDK and then copied the Oracle files directly into the lib or lib64 directories… My “improvement” avoids possible library collisions because the Oracle files are kept completely separate from an existing Java installation, so openJDK does not have to be uninstalled.

TSU