Wednesday, 27 June 2012

Installing numpy and scipy inside a virtualenev

Prerequisites:
  • sudo apt-get install git gfortran g++
  • sudo apt-get install libatlas-base-dev liblapack-dev
And:
  • pip install numpy scipy

How to install virtualenv, virtualenvwrapper in ubuntu

Follow below:

  • sudo apt-get update
  • sudo apt-get install python-setuptools python-dev build-essential git-core -y
  • sudo easy_install pip
  • sudo pip install virtualenv
  • sudo pip install virtualenvwrapper
  • mkdir ~/virtualenvs 
  •  echo "export WORKON_HOME=~/virtualenvs" >> ~/.bashrc
  •  echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc 
  •  echo "export PIP_VIRTUALENV_BASE=~/virtualenvs" >> ~/.bashrc 
  •  source ~/.bashrc 

  • mkvirtualenv blog

If you want to get out/off your virtualenv use this command:

  • deactivate

If you want to jump back on the virtualenv we just created and installed django use this command:

  • workon xxx
 
And finally if you want to remove the virtualenv altogether

  • rmvirtualenv blog 
     
     
     
      
Setup Eclipse: interpreter
Create a new PyDev Project

File -> New -> PyDev Project
A window will popup asking about the project details. Alternatively if you have already created a project go to
Project -> Properties
Click on "Click here to configure an interpreter no listed"
Click the New button
A new window will popup
Interpreter name: VIRTUALENVNAME (or whatever you like)
Interpreter executable: ~.virtualenvs/VIRTUALENVNAME/bin/python (or your custom location to the virtualenv/bin/python)

Tuesday, 26 June 2012

Standard Directory Layout in Maven

Have you ever wondered like me, what is the standard folder structure in maven?
Look here: Standard Folder Structure in Maven

Monday, 25 June 2012

Which dependency in the hierarchy does Maven use when managing dependencies

A misconception about Maven's dependency management is that “Maven chooses the highest version” when two or more transitive dependencies disagree on the version of a given groupId and ArtifactId coordinate.

The truth is that it uses Maven resolves the version nearest to the top of the dependency tree in the end. To view this dependency tree type:

 mvn dependency:tree

resource: Maven dependency management

Setting up jdk path (JAVA_HOME) for Tomcat7 in ubuntu

If you are a newbie like me, you might have the same problem as me when you wanted to start the tomcat7 on ubuntu:
  • no JDK found - please set JAVA_HOME
Make sure the JAVA_HOME is set properly: if issuing "echo $JAVA_HOME" does not show any paths, you should add the following lines to your ~./bashrc (if you want to set it locally ) or if you want to set it globally you should add these to /etc/bash.bashrc :


#Java Environment Variable
JAVA_HOME=/usr/lib/jvm/jdk1.7.0/
export JAVA_HOME
JRE_HOME=/usr/lib/jvm/jdk1.7.0/jre
export JRE_HOME
PATH=$PATH:$JAVA_HOME:$JRE_HOME
export PATH

Now, normally, after reopening the terminal and issuing "sudo service tomcat7 start" should start the tomcat. But if you see the error above again:

  • no JDK found - please set JAVA_HOME


Just to this: "gksudo gedit /etc/default/tomcat7" and uncomment the line that sets the JAVA_HOME variable:


Now run the tomcat. This should do the trick.
If you are interested in seeing some examples in Java 8, checkout my new blog about Java 8 Examples click on this link: Java 8 Examples

Thursday, 21 June 2012

Difference between "Provided" and "Compiled" scopes Maven?

Q: Maybe this question seems to be a cliché but it bothers me somehow. What it difference in using maven scope compile and provided when artifact is builded as a JAR? If it was WAR, then I understand - artifact would be attached or not to WEB-INF/lib. But in case of the JAR it doesn't matter - dependencies aren't attached. They have to be on classpath when their scope is compile or provided. I know that provided dependencies aren't transitive - but is it only one difference?

A:
From the Maven Doc:
  • compile
This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
  • provided
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

Recap:
  • dependencies are not transitive (as you mentioned)
  • provided scope is only available on the compilation and test classpath, whereas compile scope is available in all classpaths.
  • provided dependencies are not packaged


Source: http://stackoverflow.com/questions/6646959/difference-between-maven-scope-compile-and-provided-for-jar-packaging