Forums > Java

[Max5] MaxSystem.locateFile

May 18, 2008 | 10:39 am

Is anyone else experiencing MaxSystem.locateFile() no longer working in Max 5?

Execution seems to get no further than the call to MaxSystem.locateFile() such that a call to locateFile in a constructor causes a instantiation of the mxj instance to fail.

Below is a simple example I was using to test what was happening. We don’t get as far as ‘post("after locatefile: "+filename);’

public class testlocatefile extends MaxObject {
public void read(String filename) {
post("before locatefile: "+filename);
String path = MaxSystem.locateFile(filename);
post("after locatefile: "+filename);

if(path == null)
post("void string");
else if(path.length() == 0)
post("empty string");
else
post(path);
}
}


May 18, 2008 | 4:19 pm

Hi Martin,

> Is anyone else experiencing MaxSystem.locateFile() no longer working
> in Max 5?

All seems fine here … the Groovy and Python libraries use it, as
does the Hypersonic SQL package. No sign of any problems so far.

– N.

Nick Rothwell / Cassiel.com Limited
http://www.cassiel.com
http://www.myspace.com/cassieldotcom
http://www.last.fm/music/cassiel
http://www.reverbnation.com/cassiel
http://www.linkedin.com/in/cassiel
http://www.loadbang.net


May 18, 2008 | 5:55 pm

Thanks Nick, … shall investigate further. I thought it might have been using the wrong max.jar in the build path in Eclipse but I have changed it over to the max.jar in the Max5 C74 directory. Can’t think what else it would be.


May 18, 2008 | 6:33 pm

On 18 May 2008, at 18:55, Martin Robinson wrote:

> I thought it might have been using the wrong max.jar in the build
> path in Eclipse but I have changed it over to the max.jar in the
> Max5 C74 directory.

I think I’m compiling against max.jar from 4.6.3 (I have it in CVS)
but run against max.jar in 5.0.2.

In any case, I’m not aware of any significant changes to the MXJ
machinery in Max5.

– N.

Nick Rothwell / Cassiel.com Limited
http://www.cassiel.com
http://www.myspace.com/cassieldotcom
http://www.last.fm/music/cassiel
http://www.reverbnation.com/cassiel
http://www.linkedin.com/in/cassiel
http://www.loadbang.net


May 18, 2008 | 7:03 pm

Hmm,

I removed my file prefence paths so I’m running a ‘clean’ install.

I can’t even use mxj quickie since (as I suspect) its constructor calls MaxSystem.locateFile. I get the error:

(mxj) unable to construct instance of quickie

Which is the same error I get when using locateFile in the constructor of another class.

Not sure if this is related to:

http://www.cycling74.com/forums/index.php?t=msg&goto=138547&rid=3645&S=2dbe44130cd6e1a3ed9f6ccd220b9006&srch=quickie#msg_138547

But it’s more tricky to get jdk versions confused on the Mac, no?


May 18, 2008 | 9:03 pm

On 18 May 2008, at 20:03, Martin Robinson wrote:

> I removed my file prefence paths so I’m running a ‘clean’ install.

I’m not sure what you mean by "file preference paths" – you know, of
course, that the Java classpath is assembled from the
max.java.config.txt config file, not from the Max app’s file
preferences. And it is, of course, a Java classpath, so there is scope
for JAR files containing broken stuff.

> But it’s more tricky to get jdk versions confused on the Mac, no?

The Mac can host multiple JDKs (I appear to have four of them here)
but I’ve never come across any situation where things have got confused.

– N.

Nick Rothwell / Cassiel.com Limited
http://www.cassiel.com
http://www.myspace.com/cassieldotcom
http://www.last.fm/music/cassiel
http://www.reverbnation.com/cassiel
http://www.linkedin.com/in/cassiel
http://www.loadbang.net


May 18, 2008 | 10:02 pm

> I’m not sure what you mean by "file preference paths" – you know, of
> course, that the Java classpath is assembled from the
> max.java.config.txt config file, not from the Max app’s file
> preferences. And it is, of course, a Java classpath, so there is scope
> for JAR files containing broken stuff.

Yes, what I mean is I usually keep a max.java.config.txt file somewhere in my home directory which is in the Max search path. The max.java.config.txt then contains the reference to a project in my Eclipse workspace for MXJ dev.

> The Mac can host multiple JDKs (I appear to have four of them here)
> but I’ve never come across any situation where things have got confused.

I was referring to the Mac being more closely tied to jdk versions than Windows. I’m still on 10.4 using jdk 1.5.0. Not sure when we’re moving to Leopard here.


May 19, 2008 | 8:22 am

> Yes, what I mean is I usually keep a max.java.config.txt file
> somewhere in my home directory which is in the Max search path. The
> max.java.config.txt then contains the reference to a project in my
> Eclipse workspace for MXJ dev.

As an aside… I’m trying to remember whether there’s a "locatefile"
message one can send to Max without resorting to an API. If so, it’s
probably worth checking whether this works properly. There may also
be a call from JavaScript – it’s a while since I looked.

Or you could install my Python or Groovy stuff and try the call from
there – this is still a call into Java via MXJ but it takes any local
Eclipse machinery out of the picture. But that’s possibly just making
the debugging process more complicated.

> I was referring to the Mac being more closely tied to jdk versions
> than Windows. I’m still on 10.4 using jdk 1.5.0. Not sure when
> we’re moving to Leopard here.

One thought would be that the JNI machinery is broken somehow, but if
you have any MXJ stuff running at all then it must be reasonably
sound…

– N.

nick rothwell — composition, systems, performance — http://
http://www.cassiel.com


May 19, 2008 | 4:54 pm

> As an aside… I’m trying to remember whether there’s a "locatefile"
> message one can send to Max without resorting to an API. If so, it’s
> probably worth checking whether this works properly. There may also
> be a call from JavaScript – it’s a while since I looked.

The File object in js gets the path OK with something like this:

function test(v)
{
f = new File(v);
post(f.foldername+"n");
}

And the absolutepath object also works fine.

I assume both of these must use the same underlying API that the mxj object via JNI is using?

> Or you could install my Python or Groovy stuff and try the call from
> there – this is still a call into Java via MXJ but it takes any local
> Eclipse machinery out of the picture. But that’s possibly just making
> the debugging process more complicated.

I installed your jython stuff and I get a whole bunch of "unable to construct instance" errors I mentioned earlier in the thread. Presumably this is one for each of the instances in the example. I didn’t try to find ScriptingEngineBase to see if there’s a locateFile() call in there but at least this shows as you say it is not (apprently) my Eclipse environment but the JVM perhaps.

I have a couple more things to try…


May 19, 2008 | 5:42 pm

OK it was really dumb. Thanks for helping me think this through aloud…

At some point (can’t think why now) I’d put a copy of max.jar in /Library/Java/Extensions along with a whole load of other jars and I failed to spot it when checking for duplicate max.jars

Oops


May 19, 2008 | 9:40 pm

On 19 May 2008, at 18:42, Martin Robinson wrote:

> At some point (can’t think why now) I’d put a copy of max.jar in /
> Library/Java/Extensions along with a whole load of other jars

As Danny repeatedly says in CSI:NY : "Boom!"

– N.

Nick Rothwell / Cassiel.com Limited
http://www.cassiel.com
http://www.myspace.com/cassieldotcom
http://www.last.fm/music/cassiel
http://www.reverbnation.com/cassiel
http://www.linkedin.com/in/cassiel
http://www.loadbang.net


Viewing 11 posts - 1 through 11 (of 11 total)