Is it possible to use J/Link in a Wolfram Programming Cloud notebook? I need it to load and use 3rd-party .jars.

  • 2
    $\begingroup$ initial testing revealed that OnlineM lets you load JLink with Needs["JLink`"], but then upon ReinstallJava[] the kernel quits. I've also seen that it uses Java 7 update 13, which is quite depressing, given that the current Java is Java 8 update 11 since Jul 15. I'd assume that CloudM uses the same as OnlineM, but haven't been able to test yet. $\endgroup$ Jul 25, 2014 at 0:00

1 Answer 1


You can load Java in the cloud, in either the interactive web interface or in deployed code. (Some things are different about those environments.)

  str = JavaNew["java.lang.String", "Hello, world!"];

"Hello, world!"

As pointed out by Andreas Lauschke, ReinstallJava[] crashed the kernel in the programming cloud interface for me as well, but interestingly it does not crash here:

  str=JavaNew["java.lang.String","Hello, world!"];

But it does not appear you can load jars, or edit the Java classpath.

jar = BinaryReadList@"HelloWorld.jar";
With[{j = jar},
  path = "jars/HelloWorld.jar";
  BinaryWrite[path, j];
  AddToClassPath[ClassPath -> path];
  {FileExistsQ@path, FreeQ[JavaClassPath[], path]}

{True, True}

I guess this is for security reasons.

  • 1
    $\begingroup$ thanks for your answer. One clarifying question: how would you go about loading custom .jars in that environment? Is there a way to upload them to Wolfram Cloud? Or at least to access them from a remote location? $\endgroup$
    – Alex Born
    Jul 25, 2014 at 16:05
  • $\begingroup$ You can upload files to the WolframCloud either in the cloud (use up arrow next to the red "New" button) or use CopyFile[-local file-,CloudObject["cloud file name"]]. Also, in a Cloud notebook, you can load jar files present in the cloud. You can't use CloudEvaluate or deployed APIFunctions to run Java code, as mfvonh has shown. $\endgroup$
    – ChadK
    Jul 25, 2014 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.