matlab java class path issue
Your experiencing issues concerning static vs dynamic classpath. A workaround for this issue is shown in this post by using ClassPathHacker.java
in order to dynamically load java classes. You may check the other responses as well for further information.
MATLAB finds persistence.xml for eclipselink only within the first few seconds
I found a solution that works though I am not terribly happy with it. When the PersistenceProviderResolverHolder is first initialized it constructs a private inner class called DefaultPersistenceProviderResolver that when asked will find the persistence.xml in your META-INF directory. Later, when you call Persistence.createEntityManagerFactory() it will ask the PersistenceProviderResolverHolder for the resolver and then ask the resolver to find the persistence.xml.
The issue when you run this in Matlab is that at some time during initialization the PersistenceProviderResolverHolder is given an Activator class that replaces the default resolver. As far as I can tell, this Activator class tries to use OSGI to find any persistance configurations. Optimally I should be able to configure things such that it would also find the persistence.xml, but so far I have been unsuccessful at this.
The solution that I came up with is to make my own copy of the DefaultPersistenceProviderResolver class and set an instance of that as the resolver in the PersistenceProviderResolverHolder. This will replace the Activator class that had been put into it and return it to looking for the persistence.xml in the META-INF folder. I really don't like doing this, but it is the only solution that I have been able to get to work in a week of working on this.
Matlab cannot see some of my java classes (not all) in jar package
I eventually found the problem which cannot be seen above. The problem (not documented anywhere) was that some of my classes use external packages that I had not imported into Matlab. I was not planning on using any of the functionalities linked with these packages.
Nevertheless, the Matlab error message that it cannot find the class is puzzling. An error message indicating that the class cannot be used because some packages are not referenced would be most useful.
If your package uses external packages, make sure to include all of the relevant jar files in the java classpath or Matlab will not see your dependent classes.
Another tip that I found useful is that the Matlab function "import" will not return an error if you enter a package that does not exist, e.g., import java.doesnotexist.*
works fine. However, import java.doesnotexist.aclass
will not work.
Jason
Matlab: using third-party java classes from within spmd
I guess this is another 'dynamic classpath' issue. Refer to Bringing Java Classes and Methods into MATLAB Workspace on how to use the 'static classpath'.
In cases where you won't depend on the static classpath use the method described in the following posts.
- MATLAB finds persistence.xml for eclipselink only within the first few seconds
- Java JPA Class for MATLAB
Related Topics
Java Swing Jtextfield Set Placeholder
How Can "This" of the Outer Class Be Accessed from an Inner Class
How to Insert a Row Between Two Rows in an Existing Excel with Hssf (Apache Poi)
Dynamic Generic Typing in Java
Differencebetween a Pointer and a Reference Variable in Java
Pros and Cons of Package Private Classes in Java
How to Serialize an Object That Includes Bufferedimages
How to Save User Settings in Java Application
How to Use Bufferedreader in Java
What Is the Use of Pattern.Quote Method
Adding New Paths for Native Libraries at Runtime in Java
Import Com.Sun.Image.Codec.Jpeg.*
Gwt: Timer and Scheduler Classes
Java Inheritance - Calling Superclass Method