Questions tagged [java]

Questions about interfacing Mathematica and Java, particularly using J/Link.

156 questions
13
votes
1 answer

MakeJavaObject on list of inhomogeneous objects belonging to the same base class

When using J/Link, how can we create an array out of objects belonging to different classes but having the same base class? Here's an example: partSource = JLink`JavaNew[ "org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource",…
Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
12
votes
1 answer

Using Java log4j in Mathematica

Someone has a code example of how log4j can be used to create logs in Mathematica? RLink uses it, as can be checked in initLogger[] function, in this file: SystemOpen@FileNameJoin@{DirectoryName@DirectoryName@FindFile["RLink`"], "RLink.m"} But it's…
Murta
  • 26,275
  • 6
  • 76
  • 166
10
votes
0 answers

J/Link doesn't work with Java 8?

I have some code that successfully uses J/Link (well... until today when something I was doing something with it that crashed the JVM, so), and I recently tried running it under Java 8. I then get a stack trace: Fatal error: cannot find the required…
Scott Morrison
  • 1,251
  • 8
  • 14
10
votes
2 answers

Automate mouse clicks with Mathematica

I need to automate mouse clicks with Mathematica. However, a similiar question was closed on this forum, without any answer. Consider the following steps: Dynamic[MousePosition[]] In this first step I dynamically show the mouse position. …
Rod
  • 3,318
  • 2
  • 24
  • 40
9
votes
1 answer

How can I connect to the IB TWS platform from Mathematica?

TWS is the trading platform of Interactive Brokers. Accessing it programmatically could be useful for various purposes. How could I access it from Mathematica ?
faysou
  • 10,999
  • 3
  • 50
  • 125
8
votes
1 answer

Why does JLink lock unopened jar-files in Windows

Since the introduction of JLink (maybe a bit later) it is possible to put jar libraries inside the directory-structure of packages. If this package is installed in one of the places Mathematica searches, the jar libraries are automatically found by…
halirutan
  • 112,764
  • 7
  • 263
  • 474
7
votes
1 answer

How to discover a Java Class Path used by LoadJavaClass?

How can I discover which path is read to load some Java class using the command: LoadJavaClass["my.java.class"]? I believe all JavaClassPath[] is scanned, but which is used?
Murta
  • 26,275
  • 6
  • 76
  • 166
7
votes
1 answer

Using enum values with J/Link

How can I pass enum values to a function when using J/Link? What is the correct syntax for typing an enum value? For example, call normalize() using NFC from here.
Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
6
votes
1 answer

How to find out the current memory on the JVM?

I want to find out the amount of memory available in the Java Virutal Machine. I tried: << Jlink`;InstallJava[];runtime = JavaNew["java.lang.Runtime"];runtime@freeMemory[] but it throws an error: JavaNew::argx0: "There is no constructor for class…
partida
  • 6,816
  • 22
  • 48
6
votes
1 answer

J/Link: Callback from J/Link into Java when Mathematica process terminates?

Is it possible to get a callback from J/Link into java when the (remote) link closes or the Mathematica process is terminated (killed) altogether?
carl lucas
  • 101
  • 5
6
votes
1 answer

Using SimMetrics Java Function on Mathematica

I would like to know if it's possible to use/install this java library on Mathematica. This library, named SimMetrics, has a lot of string similarity functions that I would like to test. Here is the list of functions: Levenstein, NeedlemanWunch,…
Murta
  • 26,275
  • 6
  • 76
  • 166
6
votes
1 answer

Incorrect number or type of argument when using Jlink to call setAccessible

I am trying to use Java reflection to access stateVector from the following package: package org.yakindu.scr.lightswitch3; public class Lightswitch3Statemachine implements ILightswitch3Statemachine { protected class SCInterfaceImpl implements…
Todd Johnson
  • 649
  • 3
  • 12
5
votes
1 answer

How do I get java to recognize import com.wolfram.jlink

I'm trying to write a java program that uses mathematica code for processing and graphs while using java for the front end. From what I've been able to glean from the j/link tutorials on the wolfram site I will need to import com.wolfram.jlink in my…
shortgosoe
  • 115
  • 4
5
votes
0 answers

IntelliJIdea front-end plugin with JLink

I did some proof-of-concept work on having Mathematica Front-End (MathSessionPane) in the IntelliJ Idea as a plugin https://github.com/dubrousky/Mathematica-REPL. It uses JLink as a runtime dependency and is available as plugin. Does it make sense…
dubroua
  • 119
  • 3
5
votes
1 answer

Creating a generic empty list with JLink

I'm trying to reproduce a Java code in Mathematica using JLink, I'm making calls to an API in a JAR file. For one of the function call an empty list of a given type is needed but I don't know the syntax to create it with JLink. The call in Java has…
faysou
  • 10,999
  • 3
  • 50
  • 125
1
2 3 4