Re: JLink : JavaNew Failure
- To: mathgroup at smc.vnet.net
- Subject: [mg66274] Re: JLink : JavaNew Failure
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Sat, 6 May 2006 01:55:16 -0400 (EDT)
- References: <e3f600$sat$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
karenechu at gmail.com wrote: > Hello, everyone, > > I am very new to J/Link but I have been fiddling with it for a while > but I just don't see what was wrong: > > I wrote a hello world program in Java and compiled it and put it in a > folder. Then I tried to call it from Mathematica using: > > Needs["JLink`"]; > InstallJava[CommandLine->"home/usr/java/bin/java"]; > AddToClassPath["home/myclasses"]; > LoadJavaClass["test"]; > > All these go well with the new class path added and > JavaClass["test",9] as output to the last line, but when: > > test1= JavaNew["test"]; > > Mathematica failed to created object because " there is no constructor > that takes zero arguments" even though I put in an explicit > constructor that takes no argument. > > I tried putting in a constructor taking an int as an argument and using > > test1= JavaNew["test",1]; (after reinstalling Java etc) > > but now the type of the argument is wrong. > > I think the class is either not properly loaded or something, but I > just dont' know what is wrong!! > Please help! > > Thanks a lot, > cheers, > Kay > Hello, Perhaps you should post your Java declaration of the constructor for test - a common mistake is to forget to make the constructor (and class!) public. David Bailey http://www.dbaileyconsultancy.co.uk