Re: Java programming and JLink
- To: mathgroup at smc.vnet.net
- Subject: [mg45485] Re: [mg45471] Java programming and JLink
- From: "Werner Schuster" <werner.schuster at netway.at>
- Date: Sat, 10 Jan 2004 00:00:33 -0500 (EST)
- References: <200401091020.FAA24647@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
> Now mathematica 5 comes with the wonderful JLink package, which makes it
> easy to work with Java inside mathematica. In some ways it's like
> Jython, a cleaner language than Java within which you can create objects
> to run on the Java VM.
> But there seems to be one important functionality missing from JLink
> (that is present in Jython): the ability to compile classes to .class
> files that can be run on any Java VM.
Well, the current J/Link provides interactive access to Java, ie. you
can use Java classe (instantiate them, use the object, invoke methods,...)
You can also evaluate Mathematica expressions in Java code.
> Am I right that this functionality is missing from JLink?
J/Link does not include a way to create Java classes with Mathematica
code. You can use Java classes but you can not create them.
> Does anyone have a workaround to suggest? I know that I can also work
> directly with Java and still call the classes that I compile there from
> inside mathematica, but in several respects it would be nice to be able
> to compile classes from mathematica as well.
I am curious as to what exactly you would like to do with this
Would you simply like to write Java programs inside
the Mathematica Frontend (which allows a more dynamic environment
for writing code than a text editor)? This is feasible, I suppose even
without (m)any modifications to J/Link (similar projects also
work, you mentioned Jython and there are other similar tools
like Beanshell (http://www.beanshell.org/) , that can also create Java
With this solution, though, you would be restricted to using only
Java method calls and the like from your code; use of Mathematica
expressions (besides the ones for accessing Java objects) would be
possible, but would require you to deploy Mathematica
(at least the Kernel) with your generated Java classes.
> Actually, it has just occurred to me while typing this that JLink may
> not even have the ability to define new Java classes. If so, that's a
> much more fundamental limitation.
Well, there was recently the discusson here on Mathgroup, on
how to introduce this capabilities to Mathematicas .Net/Link (which is
basically the same as J/Link, but for Microsofts .NET).
Maybe some of the insights for that effort can be reused for J/Link,
mostly how to support more of the Java syntax inside of Mathematica
(how to write a class definition, a method implementation,...).
Werner Schuster (murphee)
Student of SoftwareEngineering and KnowledgeManagement
Maintainer of the OGO-JOGI Project @ http://ogo-jogi.sourceforge.net/
Prev by Date:
Re: Palette rememberance
Next by Date:
Re: Re: Palette rememberance
Previous by thread:
Java programming and JLink
Next by thread:
Evaluation of numeric Functions in NMinimize