Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Saturday, October 11, 2014

Adding an external JDK to gentoo

Oracle keeps on making it hard to install java directly. On gentoo system if you do:
neptune ~ # emerge oracle-jdk-bin

 * IMPORTANT: 6 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) dev-java/oracle-jdk-bin-1.7.0.65
 * Fetch failed for 'dev-java/oracle-jdk-bin-1.7.0.65', Log file:
 *  '/var/tmp/portage/dev-java/oracle-jdk-bin-1.7.0.65/temp/build.log'
 *
 * Oracle requires you to download the needed files manually after
 * accepting their license through a javascript capable web browser.
 *
 * Download the following files:
 *   jdk-7u65-linux-i586.tar.gz
 * at 'http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html'
 * and move them to '/usr/portage/distfiles'
 *

>>> Failed to emerge dev-java/oracle-jdk-bin-1.7.0.65, Log file:

>>>  '/var/tmp/portage/dev-java/oracle-jdk-bin-1.7.0.65/temp/build.log'

 * Messages for package dev-java/oracle-jdk-bin-1.7.0.65:

 * Fetch failed for 'dev-java/oracle-jdk-bin-1.7.0.65', Log file:
 *  '/var/tmp/portage/dev-java/oracle-jdk-bin-1.7.0.65/temp/build.log'


Which means you need to hit their webpage directly and download the "exact" version of the jdk, then copy it to the specified directory, to proceed with the installation. This is really pain. Alternativley you can download the JDK directly, and place it any where you want. Now to make it avaialble through "java-config", there's additional work needs to be done.
  • cd to /usr/share/java-config-2/vm
  • Create a file indicating the name and version of the jdk you want to manage through java-config. For example oracle-jdk-1.7
  • Copy the following into the file:
    VERSION="Oracle JDK 1.7.0_67" 
    JAVA_HOME="/opt/jdk1.7.0_67"
    JDK_HOME="/opt/jdk1.7.0_67"
    JAVAC="${JAVA_HOME}/bin/javac"
    PATH="${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin"
    ROOTPATH="${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin"
    LDPATH="${JAVA_HOME}/jre/lib/i386/:${JAVA_HOME}/jre/lib/i386/native_threads/:${JAVA_HOME}/jre/lib/i386/xawt/:${JAVA_HOME}/jre/lib/i386/server/"
    MANPATH="${JAVA_HOME}/man"
    PROVIDES_TYPE="JDK JRE"
    PROVIDES_VERSION="1.8"
    # Taken from sun.boot.class.path property
    BOOTCLASSPATH="${JAVA_HOME}/jre/lib/resources.jar:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/jre/lib/jsse.jar:${JAVA_HOME}/jre/lib/jce.jar:${JAVA_HOME}/jre/lib/charsets.jar"
    GENERATION="2"
    ENV_VARS="JAVA_HOME JDK_HOME JAVAC PATH ROOTPATH LDPATH MANPATH"
    VMHANDLE="oracle-jdk-1.7"
    BUILD_ONLY="FALSE"
    

    you will need to modify the path to point to your JDK.
  • cd /usr/lib/jvm/
  • Create a symbolic link to the home of you JDK. The link name should be exactely the same as in the field "VMHANDLE" in the file. For example:
    neptune jvm # ln -s /opt/jdk1.7.0_67/ oracle-jdk-1.7
  • Test it with java-config -L. You should see your new JDK installed and you can select it with "java-config -S 1", then java -version.

Friday, June 22, 2012

eclipse seizure - 1

In some cases when you are trying to install a  eclipse plugin through their update manager, and you are on Linux, you may get something like:


Cannot complete the install because one or more required items could not be found. Software currently installed: Shared profile ....... etc.

It happened to me many times. What do to ?

Login as root, and install the updates you need. Big chance it may work. You may try to change the permissions for the base eclipse installation, but I didn't try this yet.


Monday, June 11, 2012

Mounting database as a file

Postgresql offers the ability to query external data. In some scenarios this can be really useful. This called SQL/MED ("SQL Management of External Data").

One of those cool scenarios is when you need to query a file inside code as if it was a database table. To do so you need to have at least postgresql-9.1.

We will use the simplest file format to demonstrate the idea.

Create a CVS file:

Year,Make,Model,Length
1997,Ford,E350,2.34
2000,Mercury,Cougar,2.38
 
 
Create a postgresql server:
 
CREATE SERVER file_server FOREIGN DATA WRAPPER "file_fdw" ;




Now it's the time to create the table:


CREATE FOREIGN TABLE test (
year int,
make text,
model text,
length float
) SERVER file_server
OPTIONS (format 'csv', filename '/tmp/test.txt', header 'true', delimiter ',', null '');
 
CREATE FOREIGN TABLE

Let's try a select:

testdb=# SELECT * from test ;                                                      
 year |  make   | model  | length 
------+---------+--------+--------
 1997 | Ford    | E350   |   2.34
 2000 | Mercury | Cougar |   2.38
(2 rows)
 



Change a value in the file, and re-run the select. You should see the changes reflected in query results.

Additional Forgein Data Wrapper exists and they are cool. Using them, you can query 'twitter', MySql tables,
LDAP servers.
 
Additional documentation:
Foreign data wrappers


 
For those who likes this idea but don't use postgresql, here's a perl utility that may help:
DBIx::FileSystem

Related documents:
http://archive09.linux.com/feature/127055 
https://github.com/bianster/mysqlfs
http://www.nongnu.org/libsqlfs/
http://www.perlmonks.org/?node_id=397814




Saturday, June 18, 2011

Connecting to samba share from windows guest on KVM

  1. Install samba server. I will not explain this here as it depends on your linux distribution.
  2. Configure it: cat /etc/samba/smb.conf
    [WorkShare]
    comment = Host Share
    path = /home/mansour/work/
    valid users = mansour
    public = yes
    writable = yes
    printable = no
  3. Now we need add "mansour" to samba users. If you don't this, you wont be able to login to the share!
    smbpasswd -a mansour
  4. start your KVM :
    kvm -m 2G -vga std -smp 2 -net nic,vlan=1 -net user,vlan=1 my-window-xp-pro.im
  5. From window Start --> Run : \\10.0.2.2\WorkShare
    enter the username and password, and you should be able to view the files in your share.

For reference: Use Windows XP on Gentoo Linux with KVM