7

There is Java tool (it is called Mallet) http://mallet.cs.umass.edu/download.php which I want to use in my .NET project.

To convert this tool to .NET library at first I've tried to build it in single .jar file using Apache Ant. I've done everything corresponding to instructions at link above.

  1. Download Developer Release from Mercurial repository.

  2. Download Apache Ant, install JDK, set JAVA_HOME var to use Apache Ant.

  3. Using Ant I've built single mallet.jar file.

And then I would to convert mallet.jar to .NET library using IKVMC. When converting, I've got a lot of warnings such as:

Warning IKVMC0108: not a class file "cc/mallet/util/tests/TestPriorityQueue$1.cl
ass", including it as resource
    (class format error "51.0")

Despite of these warnings, mallet.dll was created. But when I try to reference to it from my .NET project, it looks "empty". It has not any classes or namespaces. I don't forget to reference to IKVM.OpenJDL.Core.

And this is unusual that I can't find any same problems in Google.

I think that problem is in warnings. And I have never worked with Ant and I don't understand all process exactly.

Mel
  • 5,837
  • 10
  • 37
  • 42
Valentin P.
  • 1,131
  • 9
  • 18

2 Answers2

7

The class format version 51 was introduced with Java 7.

IKVM most likely doesn't support that version yet and the file name you quote (cc/mallet/util/tests/TestPriorityQueue$1.class) points at an anonymous inner class of TestPriorityQueue that certainly is needed for the library to work correctly.

My suggestion: compile Mallet using an older JDK or at least using the -source and -target switches set to 6 (to ensure that it's compile for Java 6).

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
  • @ValentinP.: **same** errors? *Including* the same version number? Then you didn't clean correctly (i.e. there were still older `.class` files lying around). Also: desinatlling Java 7 should not be necessary. Setting `JAVA_HOME` to point to the desired JDK should be enough. – Joachim Sauer Oct 24 '11 at 13:05
  • Then make sure to delete all `.class` files in the build directory before re-building the jar file. – Joachim Sauer Oct 24 '11 at 13:13
  • Exactly same warnings. For example "Warning IKVMC0108: not a class file cc/mallet/util/tests/TestPriorityQueue.class", including it as resource (class format error "51.0")". Is it anonymous inner clas too? And can you explain, please, more preciously what "clean correctly" means? Because of by default there are a lot of .class files in corresponding Mallet folders. – Valentin P. Oct 24 '11 at 13:18
  • Arghhhh... I don't understand something. First, I build mallet.jar using Apache Ant. Second, I delete all .class files (it was a lot of them). Third, I build .dll using ikvmc. And I again get these warnings. I don't know how it is possible because files are deleted. – Valentin P. Oct 24 '11 at 13:30
  • @ValentinP.: you **still** have the `.class` files from your first compilation with Java 7 lying around (or you're still building with Java 7). You must remove them. Usually the `build.xml` has a `clean` target that does that for you. – Joachim Sauer Oct 24 '11 at 13:30
  • I look at build.xml. "jar" target which I use to create mallet.jar depends on "compile", which consist of javac. Every time I try to make mallet.jar all .class files restores. Another thing I try is to move around mallet.jar. Now I got another problem - ikvmc find main method and tries to create .exe. Moreover I get "missing class" warnings and such as "Warning IKVMC0111: emitted java.lang.NoClassDefFoundError in "cc.mallet.util.res ources.wn.Examples.demonstrateTreeOperation(Lnet.didion.jwnl.data.IndexWord;)V" ("net.didion.jwnl.data.PointerUtils")". – Valentin P. Oct 24 '11 at 13:53
  • A lot of warnings, but .exe which I've got now can be added to .NET project. And it seems to be not empty. Try to use it. Thanks! – Valentin P. Oct 24 '11 at 14:02
  • Version 51 (Java 7) now seems to be supported in IKVM, but version 52 is not. Stumbled across this answer in my own search and it was helpful so I thought I'd contribute new knowledge – Matt Thomas Oct 17 '15 at 14:23
6

FYI v8.1 (currently in RC) of IKVM supports Java 8:

http://weblog.ikvm.net/2015/08/26/IKVMNET81ReleaseCandidate0.aspx http://sourceforge.net/p/ikvm/mailman/message/34502991/

csauve
  • 5,904
  • 9
  • 40
  • 50