<?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/"
	>

<channel>
	<title>aaron-kelley.net &#187; Java</title>
	<atom:link href="http://aaron-kelley.net/blog/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://aaron-kelley.net</link>
	<description>My little corner of the Internet</description>
	<lastBuildDate>Tue, 31 Jan 2012 01:57:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Can&#8217;t pin Eclipse to the taskbar in Windows 7</title>
		<link>http://aaron-kelley.net/blog/2010/11/cant-pin-eclipse-to-the-taskbar-in-windows-7/</link>
		<comments>http://aaron-kelley.net/blog/2010/11/cant-pin-eclipse-to-the-taskbar-in-windows-7/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 12:06:09 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://aaron-kelley.net/?p=897</guid>
		<description><![CDATA[Mildly annoying problem with a simple solution. If you use the Eclipse IDE on Windows 7, you may notice that it does not behave nicely on the taskbar.  If you pin it to the taskbar, once your workspace is open, Eclipse will add a second icon to the taskbar (and right-clicking it does not yield [...]]]></description>
			<content:encoded><![CDATA[<p>Mildly annoying problem with a simple solution.</p>
<p>If you use the Eclipse IDE on Windows 7, you may notice that it does not behave nicely on the taskbar.  If you pin it to the taskbar, once your workspace is open, Eclipse will add a second icon to the taskbar (and right-clicking it does not yield any option to pin it).  From what I&#8217;ve read, you may have to be using the 64-bit version of Eclipse to experience this issue.</p>
<p>To fix it, you need to add the path to your 64-bit JDK&#8217;s bin directory to your system <tt>PATH</tt> variable.  And, it needs to come <em>before</em> <tt>C:\Windows\system32</tt> on your <tt>PATH</tt>.</p>
<p>The reason for this is Eclipse will execute under <tt>C:\Windows\system32\javaw.exe</tt> if that is the first potential JVM that it finds.  Eclipse only demonstrates this troublesome taskbar behavior when it is running under <tt>javaw.exe</tt>.  If you add a JDK path to the <tt>PATH</tt> variable that it will find first, it will use that JDK&#8217;s <tt>jvm.dll</tt> as the JVM and everything will be fine.</p>
<p>If you need help figuring out how to set your system <tt>PATH</tt> variable or where your JDK is installed, consult Google.  If you&#8217;re using Eclipse, then you must be a programmer, so I am assuming that you know about such things.</p>
<p>That&#8217;s all!</p>
]]></content:encoded>
			<wfw:commentRss>http://aaron-kelley.net/blog/2010/11/cant-pin-eclipse-to-the-taskbar-in-windows-7/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>MySQL, Tomcat 6, and Ubuntu 9.10: Blah</title>
		<link>http://aaron-kelley.net/blog/2010/01/mysql-tomcat-6-and-ubuntu-9-10-blah/</link>
		<comments>http://aaron-kelley.net/blog/2010/01/mysql-tomcat-6-and-ubuntu-9-10-blah/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 22:23:43 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://aaron-kelley.net/?p=684</guid>
		<description><![CDATA[Trying to set up a JSP application on Ubuntu 9.10, using Tomcat 6 and MySQL 5.1 (both from the Ubuntu repositories).  I was getting a curious error when trying to get a connection to the MySQL database from the JDBC DriverManager: SQLException: Communications link failure The last packet sent successfully to the server was 0 [...]]]></description>
			<content:encoded><![CDATA[<p>Trying to set up a JSP application on Ubuntu 9.10, using Tomcat 6 and MySQL 5.1 (both from the Ubuntu repositories).  I was getting a curious error when trying to get a connection to the MySQL database from the JDBC DriverManager:</p>
<blockquote><p>SQLException: Communications link failure<br />
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.<br />
SQLState: 08S01<br />
VendorError: 0</p></blockquote>
<p>After searching for a while and going through some solutions that didn&#8217;t work for me, I found the answer <a href="http://demoniosypinguinos.wordpress.com/2009/12/01/configurar-tomcat-para-mysql-en-ubuntu-9-10/" target="_blank">here</a>.  I&#8217;m re-posting it because that answer is posted in Spanish.  <img src='http://aaron-kelley.net/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
<p>All you have to do is open <tt>/etc/init.d/tomcat6</tt> in your favorite text editor (as root), find the line that looks like <tt>TOMCAT6_SECURITY=yes</tt>, and change it to <tt>TOMCAT6_SECURITY=no</tt>.  Then, restart the Tomcat server (<tt>sudo service tomcat6 restart</tt>).  Ta da!!  MySQL connections are now working.</p>
<p>Now, there&#8217;s probably a better way to do this that doesn&#8217;t involve completely turning off &#8220;<tt>TOMCAT6_SECURITY</tt>,&#8221; but this seems fine for a small test project which is what I&#8217;m working on (it will eventually be deployed on the JBoss server).  I&#8217;ll be sure to update this post if I find it&#8230; or if you know anything, leave a note in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://aaron-kelley.net/blog/2010/01/mysql-tomcat-6-and-ubuntu-9-10-blah/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Java icon appears in system tray, even when you told it not to?</title>
		<link>http://aaron-kelley.net/blog/2008/07/java-icon-appears-in-system-tray-even-when-you-told-it-not-to/</link>
		<comments>http://aaron-kelley.net/blog/2008/07/java-icon-appears-in-system-tray-even-when-you-told-it-not-to/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 18:42:13 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://aaron-kelley.net/?p=25</guid>
		<description><![CDATA[Alright, here&#8217;s some Sun Java silliness I ran across a while back and just found the fix for. If you&#8217;re running Java applications on Windows, you may have noticed that Sun likes you to see a Java icon in the system notification area when a Java application is running. You can get rid of it [...]]]></description>
			<content:encoded><![CDATA[<p>Alright, here&#8217;s some Sun Java silliness I ran across a while back and just found the fix for.</p>
<p>If you&#8217;re running Java applications on Windows, you may have noticed that Sun likes you to see a Java icon in the system notification area when a Java application is running.  You can get rid of it by right-clicking on it and selecting &#8220;Hide icon,&#8221; but it&#8217;ll just come back next time.  There&#8217;s an option in the Java control panel to hide the icon&#8230;  But sometimes, in Vista, it shows up even though you&#8217;ve told it to hide.</p>
<p><span id="more-25"></span></p>
<p style="text-align: center;"><img class="size-full wp-image-26 aligncenter" title="Java tray icon" src="http://aaron-kelley.net/wp-content/uploads/2009/07/20080716_java-tray.png" alt="20080716_java-tray" width="537" height="689" /></p>
<p>Here&#8217;s the solution.</p>
<p>Open an <em>elevated</em> command prompt.  Navigate to the Java JRE&#8217;s bin folder&#8230;  at present, on my machine, it is &#8220;<tt>C:\Program Files (x86)\Java\jre1.6.0_07\bin</tt>&#8220;.  Run javacpl.exe.  The Java control panel will open.  If you go check, you&#8217;ll notice that the option to show the icon in the system tray is still checked, even if you unchecked it before&#8230;  It seems that the setting is kept independently for elevated applications and non-elevated applicaitons.</p>
]]></content:encoded>
			<wfw:commentRss>http://aaron-kelley.net/blog/2008/07/java-icon-appears-in-system-tray-even-when-you-told-it-not-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Started with JNI and C++ under Windows</title>
		<link>http://aaron-kelley.net/blog/2007/09/getting-started-with-jni-and-c-under-windows/</link>
		<comments>http://aaron-kelley.net/blog/2007/09/getting-started-with-jni-and-c-under-windows/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 01:35:58 +0000</pubDate>
		<dc:creator>Aaron</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://aaron-kelley.net/?p=65</guid>
		<description><![CDATA[This is a step-by-step guide to getting started at using JNI with C++ under Windows. JNI is pretty much a method to call C/C++ functions from a Java application. (Actually, calling native code written in other languages, including assembly, is supported as well, but here I am focusing on C++.) This guide should give you [...]]]></description>
			<content:encoded><![CDATA[<p>This is a step-by-step guide to getting started at using <a href="http://en.wikipedia.org/wiki/Java_Native_Interface" target="_blank">JNI</a> with C++ under Windows.</p>
<p><span id="more-65"></span>JNI is pretty much a method to call C/C++ functions from a Java application.  (Actually, calling native code written in other languages, including assembly, is supported as well, but here I am focusing on C++.)  This guide should give you all you need to know to get JNI working quickly.</p>
<p>The JNI documentation for Java 1.6 is located <a href="http://java.sun.com/javase/6/docs/technotes/guides/jni/" target="_blank">here</a>.  The JNI 6.0 Specification is a good place to look, in fact, you&#8217;re going to read some of that to know how to call Java functions from C/C++, which Java types correspond to which C/C++ types, and so on.  What the spec lacks is concrete information on how to get JNI working.  In Chapter 2, they discuss how to name your C function and give some sample code.  I could not get this to work, so I went off looking for better examples elsewhere.</p>
<p>Anyway, here&#8217;s what you do.</p>
<p>First, you must create a Java class with prototypes for the native functions that you want to use.  You declare a function native just by including the keyword &#8216;native&#8217; in its declaration, for instance, &#8216;<tt>static native double f();</tt>&#8216; is a static function that takes no parameters and returns a double.  Note that you just end the function declaration with a semi-colon, you do not write any code for the function here.</p>
<p>This class may contain any other Java code that you like.</p>
<p>Next, you generate a header file using the native function declarations in your Java class.  The JDK includes a program called <tt>javah</tt> that does this for you.  If you have a class named <tt>MyClass</tt>, then open a command prompt and go to the directory containing <tt>MyClass.class</tt> and run the command <tt>javah MyClass</tt>.  This will generate <tt>MyClass.h</tt>.</p>
<p>Now, you must create a <tt>.cpp</tt> file and implement at a minimum all of the functions declared in <tt>MyClass.h</tt>, and compile the results to a DLL.  For information on how to do this with Microsoft Visual C++ 2005 Express Edition, see my <a href="index.php?itemid=8">previous post</a>.  I also have had success using gcc with Cygwin, see below.*  Your <tt>.cpp</tt> file should include the <tt>.h</tt> file that was generated.  You may link this code to whatever other C++ code you like (I am writing a JNI wrapper for an existing C++ library).</p>
<p>Note that when you compile this, it&#8217;s going to be looking for files in the JDK&#8217;s include folder.  You&#8217;ll need to make sure that you add this to your include path.  For instance, for me, I had to add &#8220;C:\Program Files (x86)\Java\jdk1.6.0_02\include&#8221; and &#8220;C:\Program Files (x86)\Java\jdk1.6.0_02\include\win32&#8243; to the include path.  These paths should be similar for you.  (For information in how to do this in Microsoft Visual C++ 2005/2008, see below.**)</p>
<p>Now that you have your DLL, you&#8217;re ready to actually call these functions from Java.  You must load your library from Java.  This is done by calling the <tt>System.loadLibrary()</tt> function in Java.  The line <tt>System.loadLibrary("MyClass");</tt> will try to load <tt>MyClass.dll</tt>, looking for it in the current working directory and all directories in the system path.  (You may also use <tt>System.load();</tt> and provide a full path to the file, using &#8216;/&#8217; instead of &#8216;\&#8217; to mark directories, for example, <tt>System.load("c:/MyClass.dll");</tt>.)</p>
<p>As long as you call <tt>System.loadLibrary()</tt> before you make any native calls, and your DLL is in the right place, <em>and</em> you named all of the native C++ functions correctly (which should be easy, since that&#8217;s done for you in the generated <tt>.h</tt> file), it should be working now.  If you get an UnsatisfiedLinkError exception when you make a native call, check to make sure that your C++ function header matches what was generated in the <tt>.h</tt> file.  If you get it when calling <tt>System.loadLibrary()</tt>, check to make sure that your DLL is in the right place.</p>
<p>* I&#8217;m assuming you&#8217;re already familiar with gcc and Cygwin.  To compile a DLL with gcc running under Cygwin, first use the command <tt>gcc -c MyClass.c</tt> to generate an object file, and then <tt>gcc -mno-cygwin -shared -Wl,--kill-at -o MyClass.dll MyClass.o</tt> to generate the DLL.  The <tt>-mno-cygwin</tt> switch makes sure that the DLL generated is not dependent on the Cygwin runtime (i.e., you won&#8217;t have to have Cygwin installed to run code out of it).  Similar compilation methods should work with g++, I haven&#8217;t tried it yet though.  (<a href="http://forum.java.sun.com/thread.jspa?threadID=708047&amp;messageID=4100932" target="_blank">source</a>)</p>
<p>** In Visual C++ 2005/2008, go to &#8220;Tools -&gt; Options&#8221;, then expand &#8220;Projects and Solutions&#8221; and select &#8220;VC++ Directories.&#8221;  Click on the drop-down menu under &#8220;Show directories for:&#8221; and choose &#8220;Include files.&#8221;  You can add include directories here, I had to add &#8220;C:\Program Files (x86)\Java\jdk1.6.0_02\include&#8221; and &#8220;C:\Program Files (x86)\Java\jdk1.6.0_02\include\win32&#8243;.</p>
]]></content:encoded>
			<wfw:commentRss>http://aaron-kelley.net/blog/2007/09/getting-started-with-jni-and-c-under-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

