<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Miks&#039; Blog</title>
	<atom:link href="http://mikaelsitruk.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikaelsitruk.wordpress.com</link>
	<description>Another weblog on Java and Programming stuffs</description>
	<lastBuildDate>Tue, 06 Dec 2011 22:21:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mikaelsitruk.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Miks&#039; Blog</title>
		<link>http://mikaelsitruk.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mikaelsitruk.wordpress.com/osd.xml" title="Miks&#039; Blog" />
	<atom:link rel='hub' href='http://mikaelsitruk.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Pig and Hbase integration</title>
		<link>http://mikaelsitruk.wordpress.com/2011/09/15/pig-and-hbase-integration/</link>
		<comments>http://mikaelsitruk.wordpress.com/2011/09/15/pig-and-hbase-integration/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 11:17:15 +0000</pubDate>
		<dc:creator>Mikael S</dc:creator>
				<category><![CDATA[Hadoop]]></category>
		<category><![CDATA[Hbase]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Pig]]></category>
		<category><![CDATA[Cloudera CDH3]]></category>
		<category><![CDATA[HBaseStorage]]></category>
		<category><![CDATA[KeeperErrorCode = ConnectionLoss]]></category>
		<category><![CDATA[map reduce]]></category>
		<category><![CDATA[zookeeper]]></category>

		<guid isPermaLink="false">http://mikaelsitruk.wordpress.com/?p=80</guid>
		<description><![CDATA[The Hadoop ecosystem contains a lot of sub project. Hbase and Pig are just some of them. Hbase is the Hadoop database, allowing to manage your data in a table way more than in a file way. Pig is a scripting language that will generate on the fly map reduce job to get the data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=80&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The Hadoop ecosystem contains a lot of sub project. Hbase and Pig are just some of them.</p>
<p><a title="Hbase" href="http://hbase.apache.org/" target="_blank">Hbase</a> is the Hadoop database, allowing to manage your data in a table way more than in a file way.</p>
<p><a title="Pig" href="http://pig.apache.org" target="_blank">Pig</a> is a scripting language that will generate on the fly map reduce job to get the data you need. It is very compact compared to hand writing map reduce job.</p>
<p>One of the nice thing between Pig and Hbase is that they can be integrated. Thanks to recent <a title="patch" href="https://issues.apache.org/jira/browse/PIG-1205" target="_blank">patch</a> committed.</p>
<p>The documentation is not well updated yet (currently almost relate to the patch itself) some can be found on some post like <span style="color:#ff0000;"><a title="here" href="http://zjffdu.blogspot.com/2010/10/using-hbasestorage-in-pig.html" target="_blank">here</a> </span>but they all lack of details explanation. Even the Cloudera distribution CDH3 indicates <a title="support for this integration" href="https://ccp.cloudera.com/display/CDHDOC/New+Features+in+CDH3" target="_blank">support for this integration</a> but no sample can be found.</p>
<p>Below I describe the installation and configuration steps to make the integration works, provide and example and finally expose some of the limits of the current release (0.8)</p>
<ol>
<li>First, install the map reduce components (Job tracker and Task tracker). One Job tracker and many task tracker as you have data nodes. Each distribution may provide different procedure for the installation, I&#8217;m using the Cloudera CDH3 distrib, which for the map reduce installation is well documented.</li>
<li>Now proceed with the Pig installation,  it is also easy as long you are not trying the integration with Hbase.  You need only to install pig on the client side, you do not need to install it on each Data Node neither on the Name Node, but just on the machine where you want to run the pig program.</li>
<li>Check your installation by entering the the grunt shell (just enter &#8216;pig&#8217; from the shell).</li>
<li>Now the tricky part &#8211; In order to use Pig/Hbase integration you in fact need to make Map Reduce jobs aware of Hbase classes, otherwise you will have <span style="color:#000080;">&#8220;ClassNotFoundException&#8221;</span> or worst the zookeeper exception like <span style="color:#000080;">&#8220;org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase&#8221;</span> during execution. The way to perform this easily <strong>without</strong> coping the hbase configurations into your hadoop configuration dir, is by using <em>hadoop-env.sh</em> and <em>hbase</em> to print its own classpath.<br />
So add to your hadoop-env.sh file file the following<br />
<pre class="brush: bash;">
#define the location of hbase
export HBASE_HOME=/usr/lib/hbase
#Customize the classpath to make map reduce job aware of Hbase
export HADOOP_CLASSPATH=&quot;`${HBASE_HOME}/bin/hbase classpath`:$HADOOP_CLASSPATH&quot;
&lt;/span&gt;</pre></li>
<li>You will also need pig to be aware of Hbase configuration, for this you can use the HBASE_CONF_DIR environment variable (for CDH release), which is configured by default to be /etc/hbase/conf,</li>
</ol>
<p>Ok your installation should be fine now, so let&#8217;s do an example&#8230;. For this example let assume we have stored in HBase a schema named TestTable, and column family named A, we have also several fields named field0, field1,&#8230;, and we want to extract this information and store it into &#8216;results/extract&#8217;.  In this case the pig script will looks like:</p>
<p><pre class="brush: plain;">
my_data = LOAD 'hbase://TestTable' USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('A:field0 A:field1', '-loadKey=true') as (id, field0, field1);

store my_data into 'results/extract' using PigStorage(';');
</pre></p>
<p>So the above script indicate that the my_data relation will contains the fields &#8220;field0, field1&#8243; and the ID (due to the -loadKey parameter). These fields will be stored as id, field0, field1 under the &#8216;result/extract&#8217; folder and values will be separated by semicolon.</p>
<p>You can also use some comparison operator on the key. The current operator supported are lt, lte, gt, gte for lower than, lower than or equal, greater than and greather than or equal.</p>
<p><span style="color:#ff6600;"> Note: There is no support for logical operator, you can use more than one comparison operator which are chained as AND.</span></p>
<p>Limitations:</p>
<p>The current HBaseStorage, does not allow the usage of wildcard, that is if you need all the fields in a row, you need to enumerate them. Wildcard are supported in version 0.9.</p>
<p>You can use HBaseStorage to store back the records in HBase nevertheless the HBase usage is incosistent a <a href="https://issues.apache.org/jira/browse/PIG-1769">bug </a>was already opened on this.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikaelsitruk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikaelsitruk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikaelsitruk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikaelsitruk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikaelsitruk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikaelsitruk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikaelsitruk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikaelsitruk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikaelsitruk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikaelsitruk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikaelsitruk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikaelsitruk.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikaelsitruk.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikaelsitruk.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=80&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikaelsitruk.wordpress.com/2011/09/15/pig-and-hbase-integration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/677c094bd785dc38fb3a306723a03ab3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">miks</media:title>
		</media:content>
	</item>
		<item>
		<title>The 1st Technion Computer Engineering (TCE) Conference &#8211; Day #2 (June 2, 2011)</title>
		<link>http://mikaelsitruk.wordpress.com/2011/06/05/the-1st-technion-computer-engineering-tce-conference-day-2-june-2-2011/</link>
		<comments>http://mikaelsitruk.wordpress.com/2011/06/05/the-1st-technion-computer-engineering-tce-conference-day-2-june-2-2011/#comments</comments>
		<pubDate>Sat, 04 Jun 2011 22:26:28 +0000</pubDate>
		<dc:creator>Mikael S</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://mikaelsitruk.wordpress.com/?p=71</guid>
		<description><![CDATA[This year the Technion, (Israel institute of technology) held the &#8220;The 1st Technion Computer Engineering (TCE) Conference (June 2, 2011)&#8220;, I registered myself to the second day (Thursday 2, June). This day topics were on &#8221;Computer Architecture &#38; Systems&#8221; and lot of lecturer both from academic and industry were present, among them I had the pleasure [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=71&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This year the Technion, (Israel institute of technology) held the &#8220;<a title="The 1st Technion Computer Engineering (TCE) Conference (June 2, 2011)" href="http://tce.technion.ac.il/">The 1st Technion Computer Engineering (TCE) Conference (June 2, 2011)</a>&#8220;, I registered myself to the second day (Thursday 2, June). This day topics were on &#8221;<em>Computer Architecture &amp; Systems</em>&#8221; and lot of lecturer both from academic and industry were present, among them I had the pleasure to listen to <strong>Leslie Lamport</strong> (from Microsoft), well known for his &#8220;Paxos algorithm&#8221; paper (see resources) and really nice other lecturers like <strong>Yale N. Patt </strong>(Texas University).</p>
<p>Below are some of my impression for this day</p>
<ul>
<li>Moore Law seems to reach limit &#8211; or at least it is not sure that the race to double the number of transistor each 18 months still the primary goal of the CMOS industry (too much core we barely need so much)</li>
<li>Parallel programming, is one of the major topic that should be learn, and we should stop creating the &#8220;its complicated&#8221; barrier on the topic</li>
<li>Security on the cloud data seems to have a major attention both by Microsoft and Intel</li>
<li>Theory (Mathematics) and Hardware knowledge are important to achieve performant programming.</li>
</ul>
<p><strong>Resources</strong></p>
<ul>
<li><a title="Paxos made simple" href="http://research.microsoft.com/en-us/um/people/lamport/pubs/pubs.html#paxos-simple">Paxos Made Simple</a> (Leslie Lamport)</li>
<li><a title="TCE - Technion Computer Engineering Conference" href="http://www.youtube.com/playlist?p=PL290778372A24464D">TCE &#8211; Technion Computer Engineering Conference</a></li>
<li><a title="The CMOS Crisis (Adjunct Prof. Doug Burger, Microsoft)" href="http://www.youtube.com/watch?v=v8VdJc8AIDI">The CMOS Crisis (Adjunct Prof. Doug Burger, Microsoft)</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikaelsitruk.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikaelsitruk.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikaelsitruk.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikaelsitruk.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikaelsitruk.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikaelsitruk.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikaelsitruk.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikaelsitruk.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikaelsitruk.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikaelsitruk.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikaelsitruk.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikaelsitruk.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikaelsitruk.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikaelsitruk.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=71&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikaelsitruk.wordpress.com/2011/06/05/the-1st-technion-computer-engineering-tce-conference-day-2-june-2-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/677c094bd785dc38fb3a306723a03ab3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">miks</media:title>
		</media:content>
	</item>
		<item>
		<title>Factors affecting C++ Compilation time &#8211; How to reduce them</title>
		<link>http://mikaelsitruk.wordpress.com/2010/08/11/speeding-up-cpp-compilation/</link>
		<comments>http://mikaelsitruk.wordpress.com/2010/08/11/speeding-up-cpp-compilation/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 20:38:48 +0000</pubDate>
		<dc:creator>Mikael S</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[compilation]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[CPP]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[decrease build time]]></category>
		<category><![CDATA[unity build]]></category>

		<guid isPermaLink="false">http://mikaelsitruk.wordpress.com/?p=49</guid>
		<description><![CDATA[Well, I never figured out to myself that I will write a C++ article when my main specialization is Java. Anyway during the last three years I&#8217;m involved in a cross discipline project involving JAVA and C++. In this project a JAVA generator generates millions of lines of C++ code which of course have to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=49&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well, I never figured out to myself that I will write a C++ article when my main specialization is Java. Anyway during the last three years I&#8217;m involved in a cross discipline project involving JAVA and C++.</p>
<p>In this project a JAVA generator generates millions of lines of C++ code which of course have to be compiled, and if you are a C++ guy you certainly already have your hair standing on your head because of the time it will require to compile such huge amount of code. Well you are right, we faced extremely long compilation time (12+ hours in Unix, in windows&#8230;), which are major problem in a product that should have a quick time to market.</p>
<p>Worst, the product is used both under Windows and Unix platforms, which means that a solution need to be created for both worlds.</p>
<p>Under Windows &#8211; even with the usage of <strong>Incredibuild </strong>from <a title="Xoreax" href="http://www.xoreax.com">Xoreax </a>(a great grid compiler platform which allowed to reduce considerably the compilation time), the user still needed to wait 2 hours for compilation, which was not acceptable.</p>
<p>Under Unix &#8211; no grid compiler (unless you work only on few platform), we tried to use <strong>distcc </strong>but the results were still not satisfying and you need additional hardware. We where stuck&#8230;</p>
<p>Therefore we begun a research for an alternative that could speed up the builds, and for that we needed to understand the factor that affected compilation time, our main suspicious factor was the number of lines of code to compile, since the code was generated, it was very easy to inflate the output nevertheless we soon understood that we were wrong&#8230;</p>
<p>Below are factors impacting the compilation time (according to their impact)</p>
<ol>
<li><strong>In the first place the number of files to compile</strong> &#8211; this is one of the <span style="color:#0000ff;"><em>major factor</em></span> affecting compilation time, the compiler is not really smart at reusing information it processed between invocation and is not able either to work on a set of files, and it is especially slow (I/O bound) for building dependencies. If you want to really reduce the compilation time reduce the number of file to compile, and it does not mean to write all in a single file, you can use what is called <a title="Unity Build" href="http://buffered.io/2007/12/10/the-magic-of-unity-builds/">Unity Build</a>.<br />
A Unity Build group several cpp files in a single one using just the include directive. For example let say you want to compile file1.cpp to file 10.cpp then create a new file group.cpp as follow:<br />
<pre class="brush: cpp;">
#include &quot;file1.cpp&quot;
#include &quot;file2.cpp&quot;
#include &quot;file3.cpp&quot;
..
..
#include &quot;file10.cpp&quot;
</pre></p>
<p>Now compile <em>group.cpp </em>and don&#8217;t forget to add the <em>file1.cpp</em>&#8230;<em>file10.cpp</em> location as include path<em>.<br />
</em>This method produces miracle (of course you have to balance the number of files you put in a single group/unity). Our compilation reduced from 15 hours to just 2.</li>
<li><strong>Include paths</strong> &#8211; large number of include path directly affect the build time, since the compiler (or pre-compiler) need to scan all the path until it find the requested include. So try to minimize them or at least organize the path list according to the most searched one.</li>
<li><strong>NAS (Network Attached Storage)</strong> also has a bad impact on the compilation (write is usually fast, but read is slow so library creation is slow).</li>
<li><strong>Generate cppdep and compile on the same time</strong> &#8211; unix compilers support option to create cppdep file and compile at the same time you can save approx 20% of your compilation time.</li>
<li><strong>Forward declaration</strong>, also know as the &#8220;Pimpl idiom&#8221; to reduce dependency, greatly help, the problem is that you cannot always refactor the code, to avoid some include that will erase your effort.</li>
<li><strong>Usage of template</strong> &#8211; using C++ template excessively increase compilation time and libraries volume (especially if the template is declared in header).</li>
<li><strong>Number of strings constants in a single file</strong>. It might should strange, but some compilers (HP and Sun at least) have a performance degradation when the compilation unit contains an large number of string (few thousand).<br />
<em><span style="color:#333399;">Note: Visual Studio compiler is not sensitive to this factor.<br />
</span></em></li>
<li><strong>Generic vs inflated code</strong> &#8211; using call to function or writing the content of function where you need them (like a forced &#8220;inline&#8221;). Inlining function in this way may produce better performance, but does not affect compilation time, as much as you think it affect. Effectively we reduced millions of lines of code by 75% using call to function instead of inlining their content, but we got no improvement in build time, but at least you gain more maintainable/debugable code.</li>
<li><strong>Usage of pre-compiled header</strong> might help, but from our test they did not, the compilation time was in fact increased.</li>
<li><strong>Usage of header cache folder</strong> &#8211; similarly to pre-compiled headers, should help (according to vendors) but from our test they most of the time do not.</li>
</ol>
<p>So if you really want to reduce your compilation time try Unity Build concept, you will gain in:</p>
<ol>
<li>Faster build time</li>
<li>Smaller objects size</li>
<li>Smaller libraries size</li>
<li>Better optimized code</li>
</ol>
<p><em>Note: The compilation time is related to the number of cpp files in a single Unity Build (and their dependencies), and this number should be tuned according to the included file content (inline, template usage, headers used&#8230;). If you have too much file in a single unity/group file compilation time increase back (still better than when no using group file), nevertheless the library size declines (even if the compilation time increased back).</em></p>
<p><em></em><br />
Mikael.Sitruk</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikaelsitruk.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikaelsitruk.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikaelsitruk.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikaelsitruk.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikaelsitruk.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikaelsitruk.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikaelsitruk.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikaelsitruk.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikaelsitruk.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikaelsitruk.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikaelsitruk.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikaelsitruk.wordpress.com/49/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikaelsitruk.wordpress.com/49/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikaelsitruk.wordpress.com/49/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=49&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikaelsitruk.wordpress.com/2010/08/11/speeding-up-cpp-compilation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/677c094bd785dc38fb3a306723a03ab3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">miks</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting up classpath from jar file</title>
		<link>http://mikaelsitruk.wordpress.com/2010/05/27/setting-up-classpath-from-jar-file/</link>
		<comments>http://mikaelsitruk.wordpress.com/2010/05/27/setting-up-classpath-from-jar-file/#comments</comments>
		<pubDate>Thu, 27 May 2010 20:39:43 +0000</pubDate>
		<dc:creator>Mikael S</dc:creator>
				<category><![CDATA[JAR]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Classpath]]></category>

		<guid isPermaLink="false">http://mikaelsitruk.wordpress.com/?p=41</guid>
		<description><![CDATA[Jar files (JAva aRchives) are very convenient containers, you can pack all you need for your application (at least for classes and resources), put the jar on the target environment and just run java -cp &#60;myapp.jar&#62; &#60;appMain&#62; &#60;command line args&#62; to execute your program. With a jar file you don&#8217;t need scripts or long command [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=41&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Jar files (<strong>JA</strong>va a<strong>R</strong>chives) are very convenient containers, you can pack all you need for your application (at least for classes and resources), put the jar on the target environment and just run <span style="color:#3366ff;">java -cp &lt;myapp.jar&gt; &lt;appMain&gt; &lt;command line args&gt; </span>to execute your program.</p>
<p>With a jar file you don&#8217;t need scripts or long command line to setup your classpath for execution.  Nevertheless if you can do better than configuring the classpath and the main from command line, you can use the manifest file for this. Doing so, you can just type <span style="color:#3366ff;">java -jar &lt;command line args&gt;</span></p>
<p>The manifest is a text file (property like) containing information on the archive, as part of this information you can define the main class of the archive and define the classpath (as long you did not pack other jar too)</p>
<p>In order to do so, define in the manifest the following tag &#8216;Class-Path&#8217; and &#8216;Main-Class&#8217;. Following is a sample:<br />
<code><br />
Main-Class: sample.package.MyMain<br />
Class-Path: directory-one/sub-directory-one/referenced.jar directory-two<span style="color:#ff0000;">/</span><br />
</code><br />
Keep in mind that:</p>
<ol>
<li>You specify several directories and/or referenced jar using a space as delimiter</li>
<li>Reference to directories and other jars are relative to the jar</li>
<li>Any referenced jar using the Class-Path attribute cannot be present in your original archive (without special classloader)</li>
<li>If you have resource in some directory don&#8217;t forget the slash at the end otherwise the content of the directory is not seen.</li>
</ol>
<p><strong>Resources</strong></p>
<p><a title="JAR file specification" href="http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html">JAR specification</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikaelsitruk.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikaelsitruk.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikaelsitruk.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikaelsitruk.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikaelsitruk.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikaelsitruk.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikaelsitruk.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikaelsitruk.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikaelsitruk.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikaelsitruk.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikaelsitruk.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikaelsitruk.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikaelsitruk.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikaelsitruk.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=41&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikaelsitruk.wordpress.com/2010/05/27/setting-up-classpath-from-jar-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/677c094bd785dc38fb3a306723a03ab3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">miks</media:title>
		</media:content>
	</item>
		<item>
		<title>Ant tip &#8211; Handling space in &#8220;exec&#8221; task.</title>
		<link>http://mikaelsitruk.wordpress.com/2009/08/28/ant-tip-handling-space-in-exec-task/</link>
		<comments>http://mikaelsitruk.wordpress.com/2009/08/28/ant-tip-handling-space-in-exec-task/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 11:20:32 +0000</pubDate>
		<dc:creator>Mikael S</dc:creator>
				<category><![CDATA[Ant]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://mikaelsitruk.wordpress.com/?p=4</guid>
		<description><![CDATA[Ant &#60;exec executable=&#8221;notepad&#8221;&#62; &#60;arg value=&#8221;c:\Documents and settings\msthoughts\doc.txt&#8221;/&#62; &#60;/exec&#62; Ant is a powerful build and script tool provided by Apache Foundation. In a recent project I used the exec task and needed to allow usage of spaces in command line argument of the called executable. A legitimate request, but if you don&#8217;t pay attention on the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=4&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Ant</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&lt;exec executable=&#8221;notepad&#8221;&gt;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&lt;arg value=&#8221;c:\Documents and settings\msthoughts\doc.txt&#8221;/&gt;</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">&lt;/exec&gt;</div>
<p><a title="ant" href="http://ant.apache.org/">Ant</a> is a powerful build and script tool provided by Apache Foundation. In a recent project I used the exec task and needed to allow usage of spaces in command line argument of the called executable. A legitimate request, but if you don&#8217;t pay attention on the different &#8217;exec&#8217;  parameters syntax, you may waste a lot of time&#8230;</p>
<p><strong>Handling space in &#8220;exec&#8221; task&#8217;s arguments.</strong></p>
<p>The exec task of ant allow to execute system command. The arguments of the command are passed as arg sub tags. The sub tag is the <strong>arg </strong>tag, followed by an attribute named <strong>value</strong>, <strong>line</strong> or <strong>path</strong>. If your argument contains space (for example a file path) do not use the <strong>line </strong>attribute, instead use the <strong>value </strong>or <strong>path </strong>ones. The <strong>line </strong>attribute will consider the spaces as separator of command line argument for the program executed.</p>
<p>For example you need to pass a text file as command line to a document editing application, and that the file is located under <em>C:\Documents and settings\msthoughts\doc.txt</em></p>
<p>Using the line attribute:</p>
<p><pre class="brush: xml;">

&lt;exec executable=&quot;myapp&quot;&gt;
  &lt;arg line=&quot;c:\Documents and settings\msthoughts\doc.txt&quot;/&gt;
&lt;/exec&gt;

</pre></p>
<p>Will produce an error since the command line is interpreted as 3 args each one denoted with brakets: [c:\Documents] [and] [settings\msthoughts\doc.txt]</p>
<p>To resolve this in command line window you usually use the quotes to wraps the command line arg having space. But using quote from ant will lead to other problem very quickly. The better solution is to use the value attribute instead of the line attribute</p>
<p><pre class="brush: xml;">

&lt;exec executable=&quot;myapp&quot;&gt;
  &lt;arg value=&quot;c:\Documents and settings\msthoughts\doc.txt&quot;/&gt;
&lt;/exec&gt;

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mikaelsitruk.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mikaelsitruk.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mikaelsitruk.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mikaelsitruk.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mikaelsitruk.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mikaelsitruk.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mikaelsitruk.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mikaelsitruk.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mikaelsitruk.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mikaelsitruk.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mikaelsitruk.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mikaelsitruk.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mikaelsitruk.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mikaelsitruk.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mikaelsitruk.wordpress.com&amp;blog=9206858&amp;post=4&amp;subd=mikaelsitruk&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mikaelsitruk.wordpress.com/2009/08/28/ant-tip-handling-space-in-exec-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/677c094bd785dc38fb3a306723a03ab3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">miks</media:title>
		</media:content>
	</item>
	</channel>
</rss>
