<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to 19: File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/</link><description>Recent changes to 19: File access throws NullPointerException</description><atom:link href="https://sourceforge.net/p/robocode/support-requests/19/feed.rss" rel="self"/><language>en</language><lastBuildDate>Tue, 09 Apr 2013 20:58:08 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/robocode/support-requests/19/feed.rss" rel="self" type="application/rss+xml"/><item><title>#19 File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/?limit=25#d31e</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;You are welcome.&lt;/p&gt;
&lt;p&gt;I agree with you regarding getting no warnings for robots that have been created for the default package. Hence I created a bug report for it here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://sourceforge.net/p/robocode/bugs/358/"&gt;https://sourceforge.net/p/robocode/bugs/358/&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Flemming N. Larsen</dc:creator><pubDate>Tue, 09 Apr 2013 20:58:08 -0000</pubDate><guid>https://sourceforge.nete4ea07de340477d1911d5e05814655fe926c9218</guid></item><item><title>#19 File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/?limit=25#177c</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;I am on windows running as admin, so it couldn't be lack of access. I run SittingDuck from within the robocode, so I started messing with my code. As it turned out it I forgot to put Lerner into package. After doing so problems disappeared, so I think my class path is ok after all. &lt;br /&gt;
I guess robocode doesn't like default package robots, which isn't that bad as it forces good practices. However I think it would be good to show some warning 'bout that after loading such robot.&lt;br /&gt;
Anyway thank you for assistance and good trails which led me to final conclusion.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/"> Rivenris</dc:creator><pubDate>Sun, 07 Apr 2013 22:27:15 -0000</pubDate><guid>https://sourceforge.netff46d8c2015e311c3bd166000d68cbbe0cddf1fe</guid></item><item><title>#19 File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/?limit=25#53be</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks for the stack trace. I have checked the code.&lt;br /&gt;
The NullPointerException is thrown as Robocode cannot create and/or write to a data file for the robots.&lt;/p&gt;
&lt;p&gt;I need more details. Do you have write permissions to write to the files (especially the 'robot' directory) under the 'robocode' directory where Robocode is installed?&lt;br /&gt;
Are you able to run SittingDuck without this error directly from Robocode? If not, something is wrong with your installation of Robocode or you have not got write permissions to the files. If it does work, your class path under the Development Options is not correct. Try to point to the 'robot' directory (containing all robots) - not directly on a individual robot directory.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Flemming N. Larsen</dc:creator><pubDate>Sun, 07 Apr 2013 21:47:08 -0000</pubDate><guid>https://sourceforge.net43260b9c04694fb9877b0662cf0249edb020898c</guid></item><item><title>#19 File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/?limit=50#9d0a</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks for the stack trace. I have checked the code.&lt;br /&gt;
The NullPointerException is thrown as Robocode cannot create and/or write to a data file for the robots.&lt;/p&gt;
&lt;p&gt;I need more details. Do you have write permissions to write to the files (especially the 'robot' directory) under the 'robocode' directory where Robocode is installed?&lt;br /&gt;
Are you able to run SittingDuck without this error directly from Robocode? If not, something is wrong with your installation of Robocode or you have not got write permissions to the files. If it does work, your class path under the Development Options is not correct. Try to point to the 'robot' directory (containing all robots) - not directly on a individual robot directory.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Sun, 07 Apr 2013 21:46:32 -0000</pubDate><guid>https://sourceforge.net2e3991ce0f697d31ec0b87b6d5ac3e53b16fb25a</guid></item><item><title>#19 File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/?limit=25#fe5f</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you for such quick response.&lt;br /&gt;
I did try code from SittingDuck example, and it ended with the same error. Also I have already defined class path properly as I was able to run my robots properly without using File access.&lt;/p&gt;
&lt;p&gt;Here is example stack trace from my error (Learner is my robot name):&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;java.lang.NullPointerException&lt;br /&gt;
        at net.sf.robocode.host.io.RobotFileSystemManager.getDataFile(RobotFileSystemManager.java:130)&lt;br /&gt;
        at net.sf.robocode.host.proxies.AdvancedRobotProxy$1.run(AdvancedRobotProxy.java:207)&lt;br /&gt;
        at net.sf.robocode.host.proxies.AdvancedRobotProxy$1.run(AdvancedRobotProxy.java:205)&lt;br /&gt;
        at java.security.AccessController.doPrivileged(Native Method)&lt;br /&gt;
        at net.sf.robocode.host.proxies.AdvancedRobotProxy.getDataFile(AdvancedRobotProxy.java:205)&lt;br /&gt;
        at robocode.AdvancedRobot.getDataFile(AdvancedRobot.java:707)&lt;br /&gt;
        at Learner.run(Learner.java:76)&lt;br /&gt;
        at net.sf.robocode.host.proxies.HostingRobotProxy.callUserCode(HostingRobotProxy.java:273)&lt;br /&gt;
        at net.sf.robocode.host.proxies.HostingRobotProxy.run(HostingRobotProxy.java:221)&lt;br /&gt;
        at java.lang.Thread.run(Unknown Source)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Line 76 in Learner.java corresponds to the 43rd line from SittingDuck.java which is opening file for reading.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;// Read file "count.dat" which contains 2 lines, a round count, and a battle count&lt;br /&gt;
    reader = new BufferedReader(new FileReader(getDataFile("count.dat")));&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Similar error happens few lines later when robot tries to open file for printing.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/"> Rivenris</dc:creator><pubDate>Sun, 07 Apr 2013 20:05:35 -0000</pubDate><guid>https://sourceforge.netaeb6dc5784a465fe94f552c39ed0ed5d8cf8ffbf</guid></item><item><title>#19 File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/?limit=25#8023</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Have a look at the source file for the SittingDuck sample robot. It gives a simple example of how to read and write to a file.&lt;br /&gt;
Also make sure you have added your class path in Robocode to where your robots a located.&lt;br /&gt;
Options -&amp;gt; Preferences -&amp;gt; Development Options&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Flemming N. Larsen</dc:creator><pubDate>Sun, 07 Apr 2013 19:43:20 -0000</pubDate><guid>https://sourceforge.net87f236e6fe2b966cc8da5b6663e93e4aaed76bbf</guid></item><item><title>#19 File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/?limit=50#580c</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Have a look at the source file for the SittingDuck sample robot. It gives a simple example of how to read and write to a file.&lt;/p&gt;
&lt;p&gt;Also make sure you have added your class path in Robocode to where your robots a located.&lt;br /&gt;
Options -&amp;gt; Preferences -&amp;gt; Development Options&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Sun, 07 Apr 2013 19:42:39 -0000</pubDate><guid>https://sourceforge.netfcc89e34607a5ba6338fecdf0d038d2f8e06f9a7</guid></item><item><title>#19 File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/?limit=25#9a9d</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;The question is how can I make data writing working?&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/"> Rivenris</dc:creator><pubDate>Sun, 07 Apr 2013 18:48:03 -0000</pubDate><guid>https://sourceforge.netbfe0eb552010468ac76aa8ffefcfb439c7deee02</guid></item><item><title>File access throws NullPointerException</title><link>https://sourceforge.net/p/robocode/support-requests/19/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;When I am trying to access data files I am getting Nulls as a result of getDataFile(...) and getDataDirectory(). &lt;br /&gt;
My robot is being developed in external IDE, and it's classpath is added correctly (code without data access is running properly).&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/"> Rivenris</dc:creator><pubDate>Sun, 07 Apr 2013 18:44:59 -0000</pubDate><guid>https://sourceforge.net3609b4cb72a845257447ed2f903b6e58ad2b2d13</guid></item></channel></rss>