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

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: Directory folder &#8211; null pointer exception on MAC only</title>
		<atom:link href="http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/feed</link>
		<description></description>
		<pubDate>Mon, 17 Jun 2013 23:19:01 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-43293</guid>
					<title><![CDATA[Directory folder &#8211; null pointer exception on MAC only]]></title>
					<link>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-43293</link>
					<pubDate>Thu, 09 Apr 2009 22:36:53 +0000</pubDate>
					<dc:creator>carob</dc:creator>

					<description>
						<![CDATA[
						<p>
<div class="pre"></div></p>
<pre>import java.io.File;

import com.cycling74.jitter.JitterMatrix;
import com.cycling74.jitter.JitterObject;

public class MoviesManager extends Thread {
	/**
	 * Constant <path_folder> - Path to the folder which contains the video
	 */
	private static final String PATH_FOLDER = "afp://bam.idmi.poly.edu/Users/carolinebouchat/Documents/videos";

	private int nbMovies;
	private File directory;
	private JitterMatrix jmOut;

	public MoviesManager(JitterMatrix jmOut) {
		directory = new File(PATH_FOLDER);
		this.jmOut = jmOut;
	}

	/**
	 * Method <freepeers> - Free peers
	 *
	 * @param m
	 *            movies
	 */
	private void freePeers(MaxVideo[] m) {
		if (m != null)
			for (int i = m.length-1; i >= 0; i++) {
				m[i].getMovie().freePeer();
				m[i].destroy();
			}
	}

	/* (non-Javadoc)
	 * @see java.lang.Thread#run()
	 */
	public void run() {
		super.run();

		File[] files;

		//while (true) {
			files = directory.listFiles();
			nbMovies = files.length;

			// If the videos' array is not created
			if (MaxTest.videos == null) {
				MaxTest.videos = new MaxVideo[nbMovies];
			}
			else {
				// Free the object
				freePeers(MaxTest.videos);
				// Reinitialize the array;
				MaxTest.videos = new MaxVideo[nbMovies];
			}

			for (int i = 0; i < nbMovies; i++) {
				// Create the video object
				MaxTest.videos[i] = new MaxVideo(new JitterObject("jit.qt.movie"), this.jmOut);

				System.out.println("file : "+files[i].getName());

				MaxTest.videos[i].getMovie()
						.send(
							"read",
"afp://bam.idmi.poly.edu/Users/carolinebouchat/Documents/videos/"+files[i].getName());
				MaxTest.videos[i].getMovie().send("autostart", 0);
				MaxTest.videos[i].start();
			}

			// Wait 5 seconds before check the folder a new time
		//}
	}
}</pre>
<p>I have a java null pointer exception on the line "files = directory.listFiles();" : so I find that come fron "nbMovies = files.length;" but I don't know why it is not working.<br />
The path is right !</p>
<p>The same class work perfectly on windows !</p>
<p>Thanks for help me.</p>
</freepeers></path_folder></pre>						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155245</guid>
					<title><![CDATA[Re: Directory folder &#8211; null pointer exception on MAC only]]></title>
					<link>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155245</link>
					<pubDate>Wed, 15 Apr 2009 06:36:34 +0000</pubDate>
					<dc:creator>Adam Murray</dc:creator>

					<description>
						<![CDATA[
						<p>I stripped it down to some simple code that I ran outside of Max:</p>
<p>
<div class="pre"></div></p>
<pre>import java.io.File;

public class AfpFileTest {

	public static void main(String args[]) {
		File directory = new File("afp://bam.idmi.poly.edu/Users/carolinebouchat/Documents/videos");
		File[] files = directory.listFiles();
		System.out.println("Found " + files.length + " files");
	}
}</pre>
<p>I can&#8217;t get it to work on either OS X or Windows. NullPointerException in both cases. directory.listFiles() is returning null. If you check the javadocs: <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#listFiles">http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#listFiles</a>() <br />
it says: &#8220;Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.&#8221;</p>
<p>I&#8217;m fairly certain this is because you are using the afp:// protocol. I&#8217;m surprised it works for you on Windows, maybe you installed some sort of special library to support it? I wouldn&#8217;t expect Apple&#8217;s proprietary remote network file system to work out-of-the-box with Java&#8217;s standard File API&#8230;</p>
<p>I&#8217;d suggest you find an alternative way to access the files. I am not familiar with afp so I don&#8217;t have any specific suggestions. But maybe there is a way to mount the remote network server so that it looks like a normal local hard drive to Java. Otherwise, I&#8217;d see if it&#8217;s possible to use http or ftp instead. Those are much more common open protocols and should be easier to get working with Java.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155246</guid>
					<title><![CDATA[Re: Directory folder &#8211; null pointer exception on MAC only]]></title>
					<link>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155246</link>
					<pubDate>Wed, 15 Apr 2009 07:06:31 +0000</pubDate>
					<dc:creator>carob</dc:creator>

					<description>
						<![CDATA[
						<p>I tried with a local path on both : <br />
   &#8211; windows : worked (local path)<br />
   &#8211; mac : never worked (local and server path)</p>
<p>To get it work on windows, you have to replace the path at 2 places : when I create the directory object and when I am looking for all files in the directory.</p>
<p>here :</p>
<div class="pre">
<pre>File directory = new File(_PATH_);</pre></div>
<p>
and here :</p>
<div class="pre">
<pre>MaxTest.videos[i].getMovie().send("read", _PATH_+files[i].getName());</pre></div>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155247</guid>
					<title><![CDATA[Re: Directory folder &#8211; null pointer exception on MAC only]]></title>
					<link>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155247</link>
					<pubDate>Wed, 15 Apr 2009 16:17:14 +0000</pubDate>
					<dc:creator>Adam Murray</dc:creator>

					<description>
						<![CDATA[
						<p>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td class="SmallText"><b>carob wrote on Wed, 15 April 2009 00:06</b></td>
</tr>
<tr>
<td class="quote">I tried with a local path on both : <br />
   &#8211; windows : worked (local path)<br />
   &#8211; mac : never worked (local and server path)</td></tr></table></p>



<p>That&#8217;s weird. Local paths should be ok. What are you using for the local path?</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155248</guid>
					<title><![CDATA[Re: Directory folder &#8211; null pointer exception on MAC only]]></title>
					<link>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155248</link>
					<pubDate>Wed, 15 Apr 2009 16:24:25 +0000</pubDate>
					<dc:creator>nick rothwell / cassiel</dc:creator>

					<description>
						<![CDATA[
						<p>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td class="SmallText"><b>carob wrote on Wed, 15 April 2009 08:06</b></td>
</tr>
<tr>
<td class="quote">
<div class="pre"></div></td></tr></table></p>
<pre>MaxTest.videos[i].getMovie().send("read", _PATH_+files[i].getName());</pre>
<p>


</p><p>Well, you don&#8217;t really want to do this&#8230; look at the File constructor with parent and child arguments:</p>
<p>< <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#File">http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#File(java.io.File,%20java.lang.String)></p>
<p>It may not solve your problem but it is a lot neater.</p>
<p>Btw, the forum software is broken, so you&#8217;ll have to select the entire URL manually.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155249</guid>
					<title><![CDATA[Re: Directory folder &#8211; null pointer exception on MAC only]]></title>
					<link>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155249</link>
					<pubDate>Wed, 15 Apr 2009 18:27:29 +0000</pubDate>
					<dc:creator>carob</dc:creator>

					<description>
						<![CDATA[
						<p>Local path work but only for windows not for mac</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155250</guid>
					<title><![CDATA[Re: Directory folder &#8211; null pointer exception on MAC only]]></title>
					<link>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155250</link>
					<pubDate>Wed, 15 Apr 2009 21:02:02 +0000</pubDate>
					<dc:creator>Adam Murray</dc:creator>

					<description>
						<![CDATA[
						<p>
<table border="0" align="center" width="90%" cellpadding="3" cellspacing="1">
<tr>
<td class="SmallText"><b>carob wrote on Wed, 15 April 2009 11:27</b></td>
</tr>
<tr>
<td class="quote">Local path work but only for windows not for mac</td>
</tr>
</table>
</p><p>
My guess is you are not forming the path correctly on Mac. Try calling file.exists() after creating the File object and make sure it&#8217;s true&#8230;</p>
<p>Sorry if I&#8217;m stating the obvious, but you realize paths will look different on Windows and Mac? So something like &#8220;C:Program FilesMax5&#8243; on Windows is going to be something like &#8220;/Applications/Max5&#8243; on Mac. </p>
<p>Since you probably need to use different paths you can do something like:</p>
<div class="pre">
<pre>if(System.getProperty("os.name").contains("Windows")) {
   // set windows path
} else {
   // set mac path
}</pre></div>
<p>
It&#8217;s also possible to find files relative to some known file in the Max installation (like your patcher file if it&#8217;s on the Max search path). This might be a better solution. I can provide more details if needed.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155251</guid>
					<title><![CDATA[Re: Directory folder &#8211; null pointer exception on MAC only]]></title>
					<link>http://cycling74.com/forums/topic/directory-folder-null-pointer-exception-on-mac-only/#post-155251</link>
					<pubDate>Thu, 16 Apr 2009 18:16:49 +0000</pubDate>
					<dc:creator>carob</dc:creator>

					<description>
						<![CDATA[
						<p>My path was wrong : I have to use the local one and no the server one.</p>
<p>Thank you for your help.</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

