MathGroup Archive 2008

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

Search the Archive

Re: FrontEnd and JLink

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87966] Re: FrontEnd and JLink
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Mon, 21 Apr 2008 06:37:33 -0400 (EDT)
  • References: <fuc7sr$a1v$1@smc.vnet.net>

I tried the following using Math.EXE, which is much the same as driving 
the kernel from Java:


  $FrontEndLaunchCommand=$InstallationDirectory<>"\\Mathematica -mathlink";

  UseFrontEnd[NotebookCreate[]]

I guess you need to wrap all relevant commands in UseFrontEnd. An 
examination of the JLink source indicates that the default FE launch 
command uses a -nogui option - so using the default launch command the 
above command seems to create an invisible notebook object.

The only problem with this (depending on your applicatio) is that you 
get an unnecessary menu bar at the top. Also, you should give it a good 
test to ensure there are no strange 'features', since I don't suppose 
many people have used this!

Unless you have already written a compled Java GUI, you may like to 
consider using my Super Widget Package (available free from my site, 
which creates a Java GUI in a very easy way, and supports a lot of Java 
features - such as, for example the MDI interface.

David Bailey
http://www.dbaileyconsultancy.co.uk





labrach at gmail.com wrote:
> I want to create Mathematica graphical objects (notebook with cells,
> palettes, plots, etc) from a Java Gui using JLink calls
> Apparently, this is not possible until you don't use the
> Mathematica.exe frontend
> (no way to initialize a frontend from a java gui)
> 
> hereafter a Java example
> Any helps ?
> 
> laurent
> 
> 
> ------------------------------------------------------------------------------------
> import com.wolfram.jlink.*;
> 
> 
> class Exemple_FrontEnd {
>    public static void main (String[] args){
> 
> try {
>   KernelLink ml = MathLinkFactory.createKernelLink("-linkmode launch -
> linkname \"MathKernel\"");
>   ml.evaluateToInputForm("Needs[\"" + KernelLink.PACKAGE_CONTEXT +
> "\"]",0);
>   ml.evaluateToInputForm("ConnectToFrontEnd[]", 0);
>   setVisible(True);
>   ml.evaluate("UseFrontEnd[NotebookCreate[]]");
> 
> } catch (MathLinkException e) {
>   e.printStackTrace();
> }
> }
> }
> 


  • Prev by Date: Re: Sorting 3 points
  • Next by Date: Re: Sorting 3 points
  • Previous by thread: FrontEnd and JLink
  • Next by thread: Mathematica syntax