• This is Slide 1 Title

    This is slide 1 description. Go to Edit HTML and replace these sentences with your own words. This is a Blogger template by Lasantha - PremiumBloggerTemplates.com...

  • This is Slide 2 Title

    This is slide 2 description. Go to Edit HTML and replace these sentences with your own words. This is a Blogger template by Lasantha - PremiumBloggerTemplates.com...

  • This is Slide 3 Title

    This is slide 3 description. Go to Edit HTML and replace these sentences with your own words. This is a Blogger template by Lasantha - PremiumBloggerTemplates.com...

Sunday, 28 April 2013

[HOW TO] Install Java on Ubuntu 12.04 LTS

[HOW TO] Install Java on Ubuntu 12.04 LTS

mdkwlan mdkwlan·16 videos
133
9,134
Like     Dislike 1
Published on Nov 17, 2012
Hey, everyone. My name is MDK. The video should be self-explanatory. If you have any Linux related problems feel free to leave a comment saying so or check out the subreddit at /r/Linux4noobs.
Take care.
Edit: This will download the most up-to-date version of java. For example as of 01/9/2013 it will download 7u10. Enjoy! -MDK

[The commands used.]
If you find any error messages from add-apt-repository please issue this command.
sudo apt-get install python-software-properties

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Once completed issue this command to make sure that Java was installed properly.
java -version.

Thanks have a good one.

How to make this for for chrome.
http://www.wikihow.com/Enable-Oracle-...

Issue the following commands. Type/Copy/Paste: sudo -s this will change you into root

Type/Copy/Paste: mkdir -p /opt/google/chrome/plugins this will create a directory called /opt/google/chrome/plugins


Type/Paste/Copy: cd /opt/google/chrome/plugins this will change you into the google chrome plugins directory,make sure you are in this directory before you make the symbolic link

Type/Paste/Copy: ln -s /usr/local/java/jre1.7.0_10/lib/i386/lib­npjp2.so this will create a symbolic link from the Java JRE( Java Runtime Environment ) plugin libnpjp2.so to your Google Chrome web browser

Uploader Comments (mdkwlan)

  • JoeHOT200
    "Command java not found".
    i did EXACTLY what it said to do
    ·
  • mdkwlan
    Then it wasn't installed properly. You missed something. Redo it.
    Do " sudo apt-get purge oracle-java7-installer "
    Then try installing it again.
    · in reply to JoeHOT200
  • Daniel Roach
    I am following what you say but I keep getting a command that say try apt-get -f...what does that mean
    ·
  • mdkwlan
    Means that it won't download unless -f is used which is force. Meaning something is off with it. Do you have the Ubuntu restricted extra's installed?
    That comes with Java and could be the reason why you're getting that error.
    · in reply to Daniel Roach
  • Gino Faustin Adefuin
    do i still need to install graphics driver for ubuntu 12.04? thanks
    ·
  • mdkwlan
    Unless you want to use the defaults. I mean they're fine if you're using an install based computer and don't have like an Nvida card or an AMD card.
    · in reply to Gino Faustin Adefuin

All Comments (77)

Sign in now to post a comment!

How to install Java 6 on ubuntu 12.04 / 12.10

How to install Java 6 on ubuntu 12.04 / 12.10

Source of Confusion: Many Versions of Java

You will find many methods to install java / jre/ jvm on web and thus it can be very much confusing to a user which method to use. Given there are many implementations of Java available, adds to the confusion. The different implementations of JDK available are:
  1. Java from Oracle (earlier provided by Sun which has been acquired by Oracle
  2. Java available from IBM
  3. OpenJDK
  4. GNU’s JDK
On an ubuntu system, one expects Java to be available as standard debian package installable with apt-get install <package-name>. But on ubuntu packages installed this way is the Open Source Version. If that suits your purpose, you can simply install it using:
$ sudo apt-get install openjdk-6-jdk
However if you wish to install the “Standard Java (earlier Sun Java)”, then it too can be installed either directly from binary distribution or from ubuntu alternate package repository.

Most Common Way:

The simplest way to install java is from a third party repository with
$ sudo add-apt-repository ppa:webupd8team/java

$ sudo apt-get update

$sudo apt-get install oracle-java7-installer

Caveat

But this works only for Java 7 as Java 6 is not available from ubuntu repositories because of licensing issues. If you download and install Java 6 locally on you machine in your home directory then it is not available to other users on the system and sometimes launching an application which is dependent upon java would be unable to find the java installed in your home directory. Moreover you have to mess with JAVA_HOME, CLASSPATH etc. environment variables. In such a case the best method is to install Java6 manually by following the steps below:

How to install Java 6 Manually

Download the jdk binary from oracles website and follow the steps below:
 $ chmod u+x jdk-6u34-linux-i586.bin
 $ ./jdk-6u34-linux-i586.bin
 $ sudo mkdir -p /usr/lib/jvm
 $ sudo mv jdk1.6.0_34 /usr/lib/jvm/
 $ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_34/bin/java" 1
 $ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_34/bin/javac" 1
 $ sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jdk1.6.0_34/jre/lib/i386/libnpjp2.so" 1

Want to install Multiple Versions of Java?

If you already have some other version of java installed on your system say like the Java 7 or say the OpenJDK then you can choose the default java to be used on your system using the update-alternative command. Running the update-alternative shows the list of alternatives for the command and you can choose one of the options listed. As an example if say there are multiple programs fulfilling the same functionality then which one is to be used by a program is not clear. For example say you have installed Aptana Studio IDE on your system which is Eclipse based then to run Aptana it requires jre. If there are multiple versions of jre installed on your system then it is not clear which one should be used to run Aptana. This is where update-alternatives comes into play. For more details check the man page of update-alternatives. To select the version of java to be used by default run the following commands and select the appropriate version.
$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config mozilla-javaplugin.so
$ sudo update-alternatives --config javaws
Running the commands above would show a prompt something like this. The details may vary on system to system.
There are 2 choices for the alternative java (providing /usr/bin/java).  
Selection Path Priority Status 
———————————————————— 
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode 
1 /usr/lib/jvm/jre1.7.0/jre/bin/java 3 manual mode  

Press enter to keep the current choice[*], or type selection number: 1

Monday, 22 April 2013

Basic PHP Crash Course (part 7)

In this post, we discuss how to retrieve or select the data from MySQL database to view our pizza order.
To do so we should create admin folder. So that we can prevent the customer from viewing our admin data.

Create a folder named admin in our pizza_shop folder.

Open the new document in your favourite editor or Notepad and type below code.



<html>
<head>
 <title>Amin Pannel</title>
</head>
<body>
<?php
 $con = mysqli_connect('localhost','root','','pizza') or die(mysqli_error());
 $sql="SELECT * FROM `order`";
 $result = mysqli_query($con,$sql) or die(mysqli_error());
 echo "<table width='100%'>";
  echo "<tr bgcolor='#FC0'>".
    "<td width='40%'>Customer Name</td>".
    "<td width='40%'>Address</td>".
    "<td width='20%' align='right'>Quantity</td>".
    "</tr>";
 while($row=mysqli_fetch_array($result)){
  echo "<tr valign='top'>".
    "<td width='40%'>".$row['name']."</td>".
    "<td width='40%'>".$row['address']."</td>".
    "<td width='20%' align='right'>".$row['quantity']."</td>".
    "</tr>";
 }#end of while loop
 echo "</table>";
?>
</body>
</html>

Save above file as index.php in our admin folder. Now if run this address http://localhost/pizza_shop/admin/ from your browser you will see like below.

Explanation

Our sql query is
"SELECT * FROM `order`"
* means all. This query will retrieve all data from our order table of pizza database.


If you familiar with programming, you can follow the code showed above picture. In this code I use while loop to show the order data.

Looping

In every programming, looping is an essential thing. In PHP, there are four kinds of looping. They are while, dowhile, for and foreach. You can use for loop if you know the looping time exactly. You can use dowhile if you want to execute at least once. If you don't know the looping time exactly, you can use while loop. The foreach loop is specially designed for use with arrays.

While Loop

This loop is simplest loop in PHP. It look like if statement. As long as the condition is true, it will execute the block repeatedly.

For our code as long as our order rows exist in our order table of the pizza database, the while loop will show the order rows.
mysqli_fetch_array($result) function will fetch the order table row one by one as an array. If there is no more rows, it will return NULL. When NULL return, while loop will stop.

Basic PHP Crash Course (part 6)

In the early posts, we do not save the order data. To deliver the user order, we have to save the order data permanently. To do so we will need suitable database server. I will use MySQL.


What is MySQL?

MySQL is a Relational Database Management System. It can store, search, sort and retrieve data efficiently. You can use it freely under the GPL license. You can check more about MySQL in its official website www.mysql.com

What do we need?

In this series, we will learn about MySQL by using phpMyAdmin. It will make you more easy to create a database by using phpMyAdmin than command line because it is a GUI(Graphical User Interfaces) system. To use phpMyAdmin you don't need to install anything if you have installed xampp or wamp as mentioned in this post.
Type this address "http://localhost/phpmyadmin/" in your browser address bar. You will see like below screenshot.




Creating our Database

Click Databases from the menu.


Type in the text box as pizza for the database name and click "Create" button.


You will see your database name in the left menu like below screenshot.


Click your database name. You will see like below screenshot.



Type order in the Name field and type 4 in the Number of columns field like below screenshot. And then click Go button to crate a database table.


Now you need to fill the field name, type etc. like below screenshot.



A database table should have a primary key. So for our order table id field should be the primary key. Select in the Index select box as PRIMARY and set the A_I(AUTO_INCREMENT) check box that will increase automatically our id field number.


Then click Save button.


Now you have created a database table to save your customer order.

PHP and MySQL

It is time to connect the MySQL database by using PHP.
Firstly I want to introduce you to the PHP built-in functions that can connect to the MySQL.

mysqli_connect("hostname","username","password","databasename")

Above function will help you to connect the MySQL database. So you need to know the parameter values.
hostname - Hostname running database server. Default is localhsot. For our xampp or wamp is also localhost.
username - Our xampp or wamp default username is root.
password - Our xampp or wamp default password is blank(no password).
databasename - Our database name is pizza.

You need to add below code to our process.php.

<?php
$con = mysqli_connect('localhost','root','','pizza') or die(mysqli_error());
$sql="INSERT INTO `order` (`name`, `address`, `quantity`) VALUES ('$cus_name', '$address', '$quantity')";
mysqli_query($con,$sql) or die(mysqli_error());
?>


First line will connect to our MySQL sever and it will also return a object which represents the connection to a MySQL Server or FALSE if the connection failed. We need to use this return object in other php function.
In second line, I create a variable of SQL statement that will use in the query function. We can write this SQL statement in the query function directly but we do so for the simplicity. This SQL statement will insert the post data from user order to the order table of our pizza database.
The third line will run our SQL Query.
Our process.php file will be like below.

<?php
 $title = "Pizza Shop: Order Process";
 include('header.php');
 include('sidebar.php');
?>
<div id="content">
<?php
 if(isset($_POST['submit']))
 {
  if( $_POST['cus_name'] != '' && $_POST['quantity'] != '' && $_POST['address'] !='' )
  {
   $cus_name = $_POST['cus_name'];
   $quantity = $_POST['quantity'];
   $address = $_POST['address'];

   $con = mysqli_connect('localhost','root','','pizza') or die(mysqli_error());
   $sql="INSERT INTO `order` (`name`, `address`, `quantity`) VALUES ('$cus_name', '$address', '$quantity')";
   mysqli_query($con,$sql) or die(mysqli_error());
?>
 <p>Thank <?php echo $cus_name; ?> !</p>
 <p>You order <?php echo $quantity; ?> pizza.</p>
 <?php
  $total = $quantity * 10;
 ?>
 <p>It will cost you <?php echo $total; ?> $.</p>
 <p>We will send withing 2 hours to <?php echo $address; ?>.</p>
 <?php
 }
 else
 {
  $_SESSION['error'] = "You need to fill all data";
  header("location: index.php");
 }
 ?>
<?php } ?>
</div><!--end of content -->
<?php
 include('footer.php');
?>

Basic PHP Crash Course (part 5)

This post is part 5 of the Basic PHP Crash Course. If you have never red before this Crash Course, you should read part 1, part 2, part 3 and part 4 first. In this post, we will discuss about our site design or template. For a website it will has header, sidebar, content and footer. So we need to add some html code to our index.php. Following code is our index.php.
<?php session_start(); ?>
<html>
<head>
 <link href="styles.css" rel="stylesheet" type="text/css">
 <title>Pizza Shop: Home</title>
</head>
<body>
 <div id="wrapper">
 <div id="header">
  <h1>Pizza Shop</h1>
 </div><!--end of header -->

 <div id="sidebar">
  <h2>Sidebar</h2>
 </div><!--end of sidebar -->

 <div id="content">
 <?php 
  if($_SESSION['error'] != '')
  {
   echo $_SESSION['error']; 
   $_SESSION['error']='';
  }
 ?>
 <h3>Pizza Shop Order Form</h3>
 <form class="order" action="process.php" method="post">
  <p>
  <label for="cus_name">Customer Name:</label>
  <input type="text" name="cus_name" />
  </p>
  <p>
  <label for="address">Shipping Address:</label>
  <input type="text" name="address" />
  </p>
  <p>
  <label for="quantity">Pizza Quantity:</label>
  <input type="text" name="quantity" />
  </p>
  <p>
  <input type="submit" name="submit" value="Submit Order" />
  </p>
 </form>
 </div><!--end of content -->

 <div id="footer">
  Pizza Shop &copy; 2011
 </div><!--end of footer -->

 </div><!--end of wrapper -->
</body>
</html>
I also create a css file named styles.css like following.
body{
 margin:0px;
 padding:0px;
}
#wrapper{
 width:960px;
 margin:0 auto;
 background-color:#FFC;
}
#header{
 height:90px;
 background-color: #FC0;
}
#header h1{
 color:#FFF;
 padding:10px 0px 0px 10px;
}
#content{
 padding:20px;
 float:left;
}
.order label{
 width:150px;
 float:left;
}
#sidebar{
 width:250px;
 height:300px;
 background-color: #C00;
 float:left;
}
#footer{
 clear:both;
 height:40px;
 background-color:#FC0;
 text-align:center;
}
Now if you run our site, you will see like below.
We have a problem. For our process.php we also need to add the html code that added to our index.php. You can add the needed code to that page. But if you have many files, you need to add every page and if you want to change some code, you will change many files. PHP has a very useful statement include() to solve this problem. It will include and evaluate the specific file. Before we use the include() statement, we will separate the duplicated coed as the separated file. Type the following code and save as header.php.
<?php session_start(); ?>
<html>
<head>
 <link href="styles.css" rel="stylesheet" type="text/css">
 <title>Pizza Shop: Home</title>
</head>
<body>
 <div id="wrapper">

 <div id="header">
  <h1>Pizza Shop</h1>
 </div><!--end of header -->
Type the following code and save as sidebar.php.
<div id="sidebar">
 <h2>Sidebar</h2>
</div><!--end of sidebar -->
Type the following code and save as footer.php.
<div id="footer">
 Pizza Shop &copy; 2011
</div><!--end of footer -->

</div><!--end of wrapper -->
</body>
</html>
Now our index.php will be like below by using include() statement.
<?php
 include('header.php');
 include('sidebar.php');
?>
<div id="content">
<?php 
 if($_SESSION['error'] != '')
 {
  echo $_SESSION['error']; 
  $_SESSION['error']='';
 }
?>
<h3>Pizza Shop Order Form</h3>
<form class="order" action="process.php" method="post">
 <p>
 <label for="cus_name">Customer Name:</label>
 <input type="text" name="cus_name" />
 </p>
 <p>
 <label for="address">Shipping Address:</label>
 <input type="text" name="address" />
 </p>
 <p>
 <label for="quantity">Pizza Quantity:</label>
 <input type="text" name="quantity" />
 </p>
 <p>
 <input type="submit" name="submit" value="Submit Order" />
 </p>
</form>
</div><!--end of content -->
<?php
 include('footer.php');
?>
Our process.php file will be like below.
<?php
 include('header.php');
 include('sidebar.php');
?>
<div id="content">
<?php
 if(isset($_POST['submit']))
 {
  if( $_POST['cus_name'] != '' && $_POST['quantity'] != '' && $_POST['address'] !='' )
  {
   $cus_name = $_POST['cus_name'];
   $quantity = $_POST['quantity'];
   $address = $_POST['address'];
?>
<p>Thank <?php echo $cus_name; ?> !</p>
<p>You order <?php echo $quantity; ?> pizza.</p>
<?php
$total = $quantity * 10;
?>
<p>It will cost you <?php echo $total; ?> $.</p>
<p>We will send withing 2 hours to <?php echo $address; ?>.</p>
<?php
  }
  else
  {
   $_SESSION['error'] = "You need to fill all data";
   header("location: index.php");
  }
?>
<?php } ?>
</div><!--end of content -->
<?php
 include('footer.php');
?>
Our template system is almost finished. Let's think about our page title. It is not flexible. I want to change my title when the page change. To do so we need to create a variable and set our title to this variable before loading the header.php. And then we can use this variable in our header.php. Below is our index.php.
<?php
 $title = "Pizza Shop: Home";
 include('header.php');
 include('sidebar.php');
?>
...
Our process.php file will be like below.
<?php
 $title = "Pizza Shop: Order Process";
 include('header.php');
 include('sidebar.php');
?>
...
Our header.php will be like below.
<?php session_start(); ?>
<html>
<head>
 <link href="styles.css" rel="stylesheet" type="text/css">
 <title><?php echo $title; ?></title>
</head>
<body>
 <div id="wrapper">

 <div id="header">
  <h1>Pizza Shop</h1>
 </div><!--end of header -->