MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Sending Objects from Java - Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90770] Sending Objects from Java - Mathematica
  • From: Jochen Adamek <tronador at cs.tu-berlin.de>
  • Date: Wed, 23 Jul 2008 05:59:44 -0400 (EDT)

Dear Mathematica-experts,

i have written a Java-code, where i want to send some objects to
Mathematica. To call a function(written in Mathematica) with four
parameters under Java, i need to send objects to Mathematica.

This is my Java-code:


public void sendListOfEdgesToMathematica(List<String> edg) throws
MathLinkException {
		try { 

		ml = MathLinkFactory.createKernelLink(argv);
			} catch (MathLinkException e) {
	        System.out.println("Fatal error opening link: " +
e.getMessage());
	        return;
	        }
			
	        try {
		ml.enableObjectReferences();
		ml.discardAnswer();	                    
ml.evaluate("<<C:\\Java\\AGG_Engine_Mathematica\\examples.nb");
		ml.discardAnswer();
		ml.putFunction("EvaluatePacket", 1);
		ml.putFunction("doGetEdges", 1);
		ml.put(edg);
                ml.endPacket();..............

edg( a list) contains the element "e11" and i have written a Function
under Mathematica for receiving the object from Java:


doGetEdges[edg_] := 
 JavaBlock[Module[{outStream}, outStream = edg@getOutputStream[];
   outStream@print["Edges"];
   edgesG6 = edg
   ]
  ]

The problem is, Mathematica does not receive the correct value("e11").
I tried to test my implementation with a PacketListener, but without
success. After sending four objects to Mathematica, i want to call the
Mathematica-function under Java:

"objectGraph[edgesG6, verticesG6, sourcesG6, targetsG6]"

Any help would be fantastic.

Best regards J.Adamek


  • Prev by Date: Re: Threading over matrices
  • Next by Date: Re: export eps
  • Previous by thread: Re: Running programs from the command line in Mathematica
  • Next by thread: FW: Sending Objects from Java - Mathematica