Re: [Ikvm-developers] java.lang.ClassNotFoundException for custom java classes
Brought to you by:
jfrijters
|
From: ¨˜”°º•<C0...@lk...> - 2011-01-21 09:25:10
|
Thanks for the info. I'll try that :) -- Manish On Fri, Jan 21, 2011 at 1:45 PM, Jeroen Frijters <je...@su...> wrote: > It can also be added via an app.config file. See here: > http://weblog.ikvm.net/PermaLink.aspx?guid=8a457a80-1e5f-4182-8f78-b2cd67845553 > > Note that you'll need to update the assembly name for the IKVM version you're using. The ikvm.runtime.ClassPathAssemblyClassLoader class lives in IKVM.OpenJDK.Core, but the easiest way to get the assembly qualified type name is to write some C#: > > Console.WriteLine(typeof(ikvm.runtime.ClassPathAssemblyClassLoader).AssemblyQualifiedName); > > You replace MyExampleAssembly with the assembly name of the IronRuby exe. > > Regards, > Jeroen > >> -----Original Message----- >> From: ¨˜”°º•C0D3w@lk3r•º°”˜¨ [mailto:c0d...@gm...] >> Sent: Friday, January 21, 2011 9:00 AM >> To: Jeroen Frijters >> Cc: ikv...@li... >> Subject: Re: [Ikvm-developers] java.lang.ClassNotFoundException for >> custom java classes >> >> Thanks a lot, that solved the issue. >> One more request, I was also experimenting this with IronRuby 1.1. Any >> idea how this attribute can be added there? >> >> -- >> Manish >> >> >> On Fri, Jan 21, 2011 at 1:18 PM, Jeroen Frijters <je...@su...> >> wrote: >> > Hi, >> > >> > Setting the CLASSPATH has no effect by default. If you want the >> CLASSPATH to be used you should apply this custom attribute to your .exe >> assembly: >> > >> > [assembly: >> IKVM.Attributes.CustomAssemblyClassLoader(typeof(ikvm.runtime.ClassPathA >> ssemblyClassLoader))] >> > >> > Regards, >> > Jeroen >> > >> >> -----Original Message----- >> >> From: ¨˜”°º•C0D3w@lk3r•º°”˜¨ [mailto:c0d...@gm...] >> >> Sent: Friday, January 21, 2011 8:32 AM >> >> To: ikv...@li... >> >> Subject: [Ikvm-developers] java.lang.ClassNotFoundException for >> custom >> >> java classes >> >> >> >> 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("CLAS >> >> SPATH")); >> >> >> >> 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 >> > > -- ¨˜”°º•C0D3w@lk3r•º°”˜¨ |