LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-09-2016, 08:44 AM   #1
LinuxToolbox
LQ Newbie
 
Registered: Sep 2016
Posts: 9

Rep: Reputation: Disabled
Command Line: "--install" followed by other stuff...Can someone break down this command for me


I am following along with a tutorial from 2dayGeek:

http://www.2daygeek.com/install-orac...rhel-opensuse/

I'm practicing this tutorial in virtual box before doing it for real, but I'm confused with one of the commands.

Let me back up for as second, as I have just done this:
Code:
$ sudo tar -zxvf jdk-8uxxx-linux-64.tar.gz
Where "8uxxx" represents the version of java 8 I downloaded

Everything went well with no errors, but now I'm supposed to do this:

Code:
$ sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.xx_xx/bin/java 2
Again, the letter "x" is used as a place holder for the current version.

Beyond "sudo" can someone tell me, section by section, what this code is supposed to do? Most importantly is java being placed on two paths simultaneously or is one the source and the other a destination? Is it a copy or a move? I'm partly confused by this because I didn't see where, in the tutorial, I was supposed to originally download and unzip my tar.gz file to (both original and unzipped files are in my Downloads folder).

Last edited by LinuxToolbox; 10-09-2016 at 08:45 AM. Reason: typo
 
Old 10-09-2016, 09:45 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,927

Rep: Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320
sudo is used to switch user, see man sudo about its functionality.
tar is a command, see man tar about it.
update-alternatives is another command, also please see the man page to understand how to use.

In general it is just: sudo command arguments
where sudo will change the user to root, the command will be executed as root. All the others, the arguments will be processed by the command.
For example -z means compression, x extract, v verbose and f will specify the file to process.
Also --install is an option to update-alternatives and /usr/bin/java java and the others will be used by it (again, see man update-alternatives and look for --install)
 
1 members found this post helpful.
Old 10-09-2016, 10:20 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by LinuxToolbox View Post
I'm partly confused by this because I didn't see where, in the tutorial, I was supposed to originally download and unzip my tar.gz file to (both original and unzipped files are in my Downloads folder).
I think the intent was that you would execute the commands in /opt as the current directory. That's why they say to use sudo with wget (which I would generally say is a bad idea).
 
1 members found this post helpful.
Old 10-10-2016, 08:16 AM   #4
LinuxToolbox
LQ Newbie
 
Registered: Sep 2016
Posts: 9

Original Poster
Rep: Reputation: Disabled
There were a few other gotcha's in the tutorial, but the few easier looking ones I saw online had more than one arguments on the same command line--where they downloaded and made java default in one step. I had already downloaded it from the official oracle link by clicking and didn't want to use up megabytes to start all over again. In my case I was able to directly start at step two in a tutorial for someone who:

1) Had openjdk but didn't want to replace it (But see note below)
2) Wanted to make Oracle Java 8 their default (Many tutorials for Java 7 still out there)
3) And again, I'm fairly new to using the command line; still learning, and non-compound commands help me learn better because I can google everything as I'm following along.

The main gotcha in the tutorial is step 7. He has a code step where he simply says you type it to make it work

Code:
$ sudo source ~/.bashrc
Not only does this not work, but in google research there are others who have combined sudo with source for other commands and had the same issue [with no resolution].

So, I wasn't sure what it supposed to do in this case but I found that
Code:
$ echo $JAVA_HOME
failed at this step. It left a blank line.

However, I thought about how many changes I had made, maybe a simple reboot would do the trick...

So now it works. Don't know exactly how. But it works.

(Note and another gotcha)
I want to state this up front that my personal favorite Java IDE is Eclipse. But I downloaded BlueJ for testing purposes because I simply wanted to do a "Hello World" in an IDE environment. It also is one of the few Java IDE's that are available with the vanilla "Search for software" function at SuseStudio (another project I have been playing around with).

Well, with the version I downloaded from an Ubuntu approved repository (not SUSE), BlueJ hasn't been set up to accept Oracle Java 8 yet, so it wouldn't unpack. So I don't know if it true for other IDE's out there, but if your IDE is set to use openjdk, you might want to leave your java settings alone.

P.S. Eclipse took over an hour to download (expected) but I tested a HelloWorld and it works fine.
 
Old 10-10-2016, 08:33 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,927

Rep: Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320Reputation: 7320
sudo source ~/.bashrc cannot work, that's true.
Also there are a lot of unnecessary sudo on that page (http://www.2daygeek.com/install-orac...rhel-opensuse/)
You may say that tutorial is not really usable.
 
1 members found this post helpful.
Old 10-10-2016, 09:00 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
> Beyond "sudo" can someone tell me, section by section, what this code is supposed to do?

This is an invocation of program 'update-alternatives', everything else are its arguments. Consult the manual if interested.

> Most importantly is java being placed on two paths simultaneously or is one the source and the other a destination? Is it a copy or a move?

Neither, it is a symlink. Or more than one symlinks. Eg:

Code:
$ ls -l /usr/bin/c99
/usr/bin/c99 -> /etc/alternatives/c99

$ ls -l /etc/alternatives/c99
/etc/alternatives/c99 -> /usr/bin/c99-gcc
 
2 members found this post helpful.
Old 10-12-2016, 06:59 AM   #7
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,503

Rep: Reputation: Disabled
When you type /usr/bin/java or java you will actually be running /opt/jdk1.8.xx_xx/bin/java 2 because it is linked to your /usr/bin directory, which is in your PATH statement.

When source ~/.bashrc is used, you are re reading your .bashrc file into memory, without having to log out & back in.
 
2 members found this post helpful.
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying text file with "one command line" SED command... daleo Linux - Newbie 3 01-13-2012 05:32 AM
[SOLVED] How do I run "menu" and "logout" from the command line in fluxbox? psionl0 Slackware 19 03-02-2011 12:46 AM
How to install "apache2" in command line in Suse for nagios? hqlgree2 Linux - Newbie 1 08-21-2008 10:08 AM
"mail" command screws up my stuff hashbangbinbash Linux - Newbie 5 04-16-2008 07:22 PM
cdrecord command-line parentheses "(" ")" coolingtower Linux - Software 1 10-28-2005 11:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration