<?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>JAVA</title>
	<atom:link href="http://java.lillegutt.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://java.lillegutt.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 05 Feb 2010 19:54:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Image to byte array and back to image in J2ME</title>
		<link>http://java.lillegutt.com/?p=22</link>
		<comments>http://java.lillegutt.com/?p=22#comments</comments>
		<pubDate>Fri, 05 Feb 2010 16:01:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java ME]]></category>
		<category><![CDATA[convert to byte array]]></category>
		<category><![CDATA[image to byte array]]></category>
		<category><![CDATA[Image.java]]></category>

		<guid isPermaLink="false">http://java.lillegutt.com/?p=22</guid>
		<description><![CDATA[I have recently been working with a mobile client where the possibility to retrieve the raw byte array from an image was important. I struggled to find any working solutions on forums all over but none was working as I wanted. Why don&#8217;t the Image.java have an option to retrieve the raw byte array? The [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been working with a mobile client where the possibility to retrieve the raw byte array from an image was important. I struggled to find any working solutions on forums all over but none was working as I wanted. Why don&#8217;t the Image.java have an option to retrieve the raw byte array?</p>
<p>The numorus options on forums included getting the RGB-data as an int array and then bit-switching to get the proper output. BUT, if you want to create an Image based on your newly created byte array, if fails with an IllegalArgumentException.</p>
<p>Here is what I did for this workaround. I&#8217;m not sure if this is the correct way to do it but in my case it did what I wanted:</p>
<pre class="brush: java;">
/**
   * Get the resource from jar-package as input stream to get the byte[] raw format
   * @param resource The local file name
   * @return The image byte array
   */
public byte[] getResourceAsByteArray(String resource){
	ByteArrayOutputStream baos = new ByteArrayOutputStream();
	InputStream bais;
	try {
		bais = (InputStream)getClass().getResourceAsStream(&quot;//&quot; + resource);
		int c;
		while((c = bais.read()) != -1){
			baos.write(c);
		}
		bais.close();
		baos.close();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return baos.toByteArray();
}
</pre>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Image+to+byte+array+and+back+to+image+in+J2ME+http://86wi6.th8.us" title="Post to Twitter"><img class="nothumb" src="http://java.lillegutt.com/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://java.lillegutt.com/?feed=rss2&amp;p=22</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java ME Installation procedure (with SDK 3.0)</title>
		<link>http://java.lillegutt.com/?p=3</link>
		<comments>http://java.lillegutt.com/?p=3#comments</comments>
		<pubDate>Mon, 25 Jan 2010 15:46:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java ME]]></category>
		<category><![CDATA[connect failed]]></category>
		<category><![CDATA[sdk 3]]></category>
		<category><![CDATA[uac]]></category>
		<category><![CDATA[uac settings]]></category>

		<guid isPermaLink="false">http://java.lillegutt.com/?p=3</guid>
		<description><![CDATA[I recently installed Windows 7 64-bit om my Dell work laptop and had a lot of issues concerning the starting of the Java ME 3.0 Service. When I started it I got ConnectException: Connection refused. I found out that I had installed the wrong version of the JDK. I installed the 64-bit version which aparently [...]]]></description>
			<content:encoded><![CDATA[<p>I recently installed Windows 7 64-bit om my Dell work laptop and had a lot of issues concerning the starting of the Java ME 3.0 Service. When I started it I got ConnectException: Connection refused.</p>
<p>I found out that I had installed the wrong version of the JDK. I installed the 64-bit version which aparently is not working well with the Java ME SDK 3.0. I was also not logged in/had an administrator account and therefore could not turn the UAC off. This is also an issue because you have&#8217;nt got the authority to run the localhost service.</p>
<p>Here is the installation how-to:</p>
<ul>
<li>Download and install the current version of JDK SE but select the 32-bit version<br />
<a href="http://java.sun.com/javase/downloads/index.jsp" target="_blank">Java SE Downloads</a></li>
<li>Download and install the current version of Java ME SDK(for now 3.0)<br />
<a href="http://java.sun.com/javame/downloads/sdk30.jsp" target="_blank">Java ME Downloads</a></li>
<li>Log in as administrator</li>
<li>Start -> Getting started (hover over arrow) -> Change UAC settings</li>
<li>Drag the slider to the bottom and press OK</li>
</ul>
<p>My currently thought is that the Java ME SDK 3.0 requires the 32-bit JDK version and will stop on &#8220;Starting modules&#8221; and give this Error in a pop up:</p>
<pre class="brush: java;">java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at java.net.Socket.&lt;init&gt;(Socket.java:372)
at java.net.Socket.&lt;init&gt;(Socket.java:186)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
Caused: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
Caused: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
Caused: java.io.IOException: Failed to retrieve RMIServer stub
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at com.sun.jme.toolkit.remoting.client.rmiimpl.ObjectServerConnectionImpl.connect(Unknown Source)
at com.sun.jme.toolkit.remoting.client.rmiimpl.ObjectServerConnectionImpl.start(Unknown Source)
Caused: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.jme.toolkit.bootstrap.Batch.invoke(Unknown Source)
at com.sun.jme.toolkit.bootstrap.Batch.tryInvoke(Unknown Source)
at com.sun.jme.toolkit.bootstrap.Batch.startObjects(Unknown Source)
at org.netbeans.modules.javame.common.container.Module.start(Module.java:21)
at org.netbeans.modules.javame.common.container.ContainerSupport.startModule(ContainerSupport.java:67)
at org.netbeans.modules.javame.common.container.devicemanager.DevicemanagerHelper.getDeviceManagerConnection(DevicemanagerHelper.java:41)
at org.netbeans.modules.javame.common.container.devicemanager.DevicemanagerHelper.ensureConnected(DevicemanagerHelper.java:48)
at org.netbeans.modules.javame.common.container.devicemanager.DevicemanagerHelper.getDeviceManager(DevicemanagerHelper.java:84)
at org.netbeans.modules.javame.platform.jme_sdk.autoinstaller.AutoInstaller.ensureDMStarted(AutoInstaller.java:292)
at org.netbeans.modules.javame.platform.jme_sdk.autoinstaller.AutoInstaller.restored(AutoInstaller.java:63)
at org.netbeans.core.startup.NbInstaller.loadCode(NbInstaller.java:421)
at org.netbeans.core.startup.NbInstaller.load(NbInstaller.java:342)
at org.netbeans.ModuleManager.enable(ModuleManager.java:906)
at org.netbeans.core.startup.ModuleList.installNew(ModuleList.java:428)
at org.netbeans.core.startup.ModuleList.trigger(ModuleList.java:364)
at org.netbeans.core.startup.ModuleSystem.restore(ModuleSystem.java:276)
at org.netbeans.core.startup.Main.getModuleSystem(Main.java:165)
at org.netbeans.core.startup.Main.start(Main.java:312)
at org.netbeans.core.startup.TopThreadGroup.run(TopThreadGroup.java:110)
[catch] at java.lang.Thread.run(Thread.java:619)
</pre>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Java+ME+Installation+procedure+%28with+SDK+3.0%29+http://8zf87.th8.us" title="Post to Twitter"><img class="nothumb" src="http://java.lillegutt.com/wp-content/plugins/tweet-this/icons/tt-twitter-big3.png" alt="Post to Twitter" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://java.lillegutt.com/?feed=rss2&amp;p=3</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
