Hot answers tagged

28 votes
Accepted

Implementing Local HTTP Server

The following guide shows how to conduct communication between nanohttpd, an http server for Java, and Mathematica. The result is a server that, if you go to its address in a web browser, displays the ...
C. E.'s user avatar
  • 70.4k
15 votes

Implementing Local HTTP Server

The following is a sample implementation of a simple HTTP server in Wolfram Language code only: https://github.com/arnoudbuzing/wolfram-server You send it a POST request where the body data of the ...
Arnoud Buzing's user avatar
10 votes

Implementing Local HTTP Server

Starting in Mathematica 12, there is a built-in function SocketListen that can start a web server and respond to HTTP requests. ...
Flux's user avatar
  • 366
7 votes

Why can 10.3.1 import a 2MB excel file, but 10.4.0 cannot, with the same commands and file?

From Wolfram support: the reason 10.4.0 cannot import the excel file: the command ReinstallJava[CommandLine -> "java", JVMArguments -> "-Xmx2048m"]; is ...
Michael B. Heaney's user avatar
7 votes
Accepted

How to launch a separate Java VM on each sub-Kernel?

I opened a case with WRI ([CASE:3994742]) where they provided a supported solution. A Java process can be launched on a sub-kernel by calling ReinstallJava on the ...
Edmund's user avatar
  • 42k
7 votes

Using ImageJ filters directly from Mathematica through J/Link

This is not an answer to the main question on how to do it in Mathematica but merely one possible reason why this whole thing might not be achievable. In Java, your exact example looks like this <...
halirutan's user avatar
  • 113k
7 votes

A JAVA Program wants call Mathematica's Reduce function to solve equation and get the result

The problem is that your Reduce returns a result of type Inequality. But then you're trying to read it as String. That's the wrong type to use, Java doesn't know what a type of Inequality is. You can ...
Andreas Lauschke's user avatar
6 votes
Accepted

J/Link stealing focus from the Front End on OS X. Workaround?

You can prevent the focus from being lost by setting certain system properties to true before calling any awt functionality: ...
WReach's user avatar
  • 68.7k
6 votes

What does it mean that GUIkit is being deprecated?

It is an indication that It is no longer under active development (or, really, any). Bug reports may be ignored unless they have severe impact (like security issues). You should try to port existing ...
Itai Seggev's user avatar
  • 14.1k
6 votes
Accepted

How to convert a Java BufferedImage to a Mathematica Image?

Courtesy of this post, one solution is to use java to get the PNG data then import it to Mathematica as Image. For that you need ...
Ben Izd's user avatar
  • 9,169
5 votes
Accepted

How to create keypress simulation program?

A summary to all the stuffs: ...
Wjx's user avatar
  • 9,558
5 votes
Accepted

How could get all escape characters in Mathematica?

The help documentation has a section called Listing of Named Characters. One way to get to it is to hit the F1 key and then paste the following into the documentation window: ...
LouisB's user avatar
  • 12.3k
5 votes

Update Java used by Mathematica 10

You may use ReinstallJava with the CommandLine option. ...
Edmund's user avatar
  • 42k
5 votes

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

After reviewing this again How to call a java method that takes a boolean (not Boolean)? I noticed that both setAccessible methods required a primitive boolean, not a Boolean object. Thus, all of ...
Todd Johnson's user avatar
5 votes
Accepted

Prevent JLink from using a DisabledPreferencesFactory with Java on Linux

From the comments around the code snippet posted, I would guess that $disablePrefs is not an exported function from the JLink package, but instead is a private ...
Jason B.'s user avatar
  • 67.9k
4 votes

Implementing Local HTTP Server

In 2023 new players joined our game TCPServer - a general purpose tcp-server written using only WL HTTPServer - an extension to TCPServer to manage GET/POST requests WebSocketServer - an extension to ...
Kirill Vasin's user avatar
  • 1,225
4 votes

Add new JDBC Driver to connect Mathematica to SQL database

In the case where you want to use an updated driver in preference to an older one shipped with Mathematica, AddToClassPath[ ...path..., Prepend -> True]. For ...
Chris F Carroll's user avatar
4 votes
Accepted

How to get the image in the clipboard with a J/Link method?

It is quite ambitious to extract an image in an arbitrary format from the clipboard using only JLink. This is because the code must anticipate variations such as ...
WReach's user avatar
  • 68.7k
4 votes
Accepted

When using Java objects through JLink, how can I multitask the objects?

Create a Java class implementing the Producer / Consumer design pattern. See also: Producer-Consumer problem. The class below is an example. Then in Mathematica instantiate the class and submit all ...
nilo de roock's user avatar
4 votes
Accepted

Need J/Link values returned in 1D instead of 2D format (i.e., not exponents, fractions, on multiple lines)

It's all right there in the name: evaluateToOutputForm. If you want it InputForm, use ...
Itai Seggev's user avatar
  • 14.1k
4 votes
Accepted

Change DataStructure (or maybe just a symbol) from JLink/Java program

I've tested this code with Mathematica's default JDK (version 11.0.12, Mathematica 13.0.1). Assume I've run an echo server on 127.0.0.1:8000. Let's import ...
Ben Izd's user avatar
  • 9,169
3 votes
Accepted

J/Link HMAC Base64

Use Base64`encodeBase64String -- with a capital "B". The expression: ...
WReach's user avatar
  • 68.7k
3 votes

Is it possible to get the locations and dimensions of all boxes in a StandardForm expression renderation?

Details depend of your specific needs but it seems that information you desire is at least partially accesible via FrontEnd`UndocumentedGetSelectionPacket. ...
Kuba's user avatar
  • 137k
3 votes
Accepted

Converting text from unsupported encodings like 866 into known by Mathematica?

UPDATE 3 Probably the most elegant complete solution (output is truncated): ...
Alexey Popkov's user avatar
3 votes
Accepted

How to get a audio file's duration time in Mathematica?

Now,in Mathematica 11. Using Duration function make it more easily: Import["ExampleData/car.mp3", "Duration"] Or ...
partida's user avatar
  • 6,786
3 votes

Implementing Local HTTP Server

Yes (and using pure Mathematica or WolframEngine) https://jerryi.github.io/tinyweb-mathematica/
Kirill Vasin's user avatar
  • 1,225
3 votes
Accepted

How to fix a "Java failed to load class" when using custom Java class using JLink?

The problem was the following, the custom .jar was created with Java 8, Mma 10.3 comes with Java 7, the real error was a version issue. ...
nilo de roock's user avatar
3 votes

J/Link HMAC Base64

The recently released version 11.3.0 introduced BaseEncode which would be useful here. A complete example (including the HMAC computation) in Mathematica: ...
ilian's user avatar
  • 25.5k
3 votes

Is there any way that convert entire mathematica code to java or python?

I am not exactly sure what you mean by "trace coding", but in general, the Mathematica evalution methods are very complicated, and could be documented better. Again, in general, in any computer ...
Somos's user avatar
  • 4,897
3 votes

Missing ticks and numbers on a plot when using JLink + Mathematica 11.3

I found the solution: Usually in the Plot[] function, the FrameTicks option is set to Automatic, which in Mathematica 9.0 or 10.0 "always" translates to True. But for some reason in Mathematica 11.3 ...
SevenEvos's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible