Re: [Ikvm-developers] java.lang.ClassNotFoundException for custom javaclasses
Brought to you by:
jfrijters
|
From: Volker B. <VB...@in...> - 2011-01-21 07:38:57
|
I think the setting of the CLASSPATH come to late. You can test this if you print System.getProperties(). A real solution will be an URLClassLoader. Volker -----Ursprüngliche Nachricht----- Von: ¨˜”°º•C0D3w@lk3r•º°”˜¨ [mailto:c0d...@gm...] Gesendet: Freitag, 21. Januar 2011 08:32 An: ikv...@li... Betreff: [Ikvm-developers] java.lang.ClassNotFoundException for custom javaclasses Hi, I'm trying to read a java object (Student) which has been serialized and stored in a file "st.bin". All the IKVM dlls are in my path. I'm using IKVM version 0.44.0.5 on Windows 7 The Student class is in the "st.jar" file. The code to do that is as follows: using System; using System.Collections.Generic; using System.Text; using java.io; namespace DotNetJavaInterop { class Program { static void Main(string[] args) { System.Environment.SetEnvironmentVariable("CLASSPATH",".;./st.jar;"); System.Console.WriteLine(System.Environment.GetEnvironmentVariable("CLASSPATH")); FileInputStream fis = new FileInputStream("st.bin"); ObjectInputStream ois = new ObjectInputStream(fis); Object obj = ois.readObject(); System.Console.WriteLine(obj.GetType().ToString()); } } } Unhandled Exception: java.lang.ClassNotFoundException: Student at java.io.ObjectInputStream.readObject() at DotNetJavaInterop.Program.Main(String[] args) in C:\..\Visual Studio 2010\Projects\DotNetJavaInterop\DotNetJavaInterop\Program.cs:line 16 This erro only occurs for custom java classes, not the existing java classes like ArrayList, etc. What is wrong here and how can I correct this? -- Manish ------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d _______________________________________________ Ikvm-developers mailing list Ikv...@li... https://lists.sourceforge.net/lists/listinfo/ikvm-developers |