Ask Your Question

Run Java in Sagemath! AWESOME! But i got errors/comment/warning!

asked 2018-02-06 11:46:00 +0200

thetha gravatar image

updated 2018-02-06 15:35:22 +0200

Hi im a running this: But I get this error/comment/warning:

Picked up _JAVA_OPTIONS: -Xms64m

Is there a way to enable the edditor to recognise java use some highlights, or like this?

edit retag flag offensive close merge delete


It is hard to understand / reconstruct the situation / the question.

The link points to some java code for some Aufgabe1 that can be easily solved in python (and sage), e.g. also with test code to find the palindroms in some test list:

sage: for w in ( 'oma', 'opa', 'rentner', 'anna', 'illuminatti' ):
....:     if w == w[::-1]:    print w

(Sure, this was not the point.)

How to run the above code (not in eclipse), and how is this related to sage? When does the error appear? How is this related to sage? Is the only question asking for Cocalc java code highlight?

Cocalc opens for me some editor with the java-like highlighted code after pressing the [Open in Cocalc] from the given link.

dan_fulea gravatar imagedan_fulea ( 2018-02-06 13:05:42 +0200 )edit

Its just one line....well i can make it look nice! :) Okey more explanition: sage can run java,phython,c++,fortran, and god knows what else! I have tried java and i get a warning. , so what does this means

thetha gravatar imagethetha ( 2018-02-06 15:34:28 +0200 )edit

Your question is about running Java code, from what I understand, either in a Jupyter worksheet (.ipynb) or in a CoCalc worksheet (.sagews). You could request help by clicking the "Help" button (emergency suitcase icon) at the top right of a CoCalc browser window. Make sure to click that button from the worksheet or file where you are experiencing the problem, this way the support team at CoCalc can access that particular worksheet or document and see what the problem is.

slelievre gravatar imageslelievre ( 2018-02-06 20:42:42 +0200 )edit

I don't see how this relates to Sage, so maybe I'm missing your question. The CoCalc editor recognizes the .java filetype and will do syntax highlighting without additional setup. Is that your question? For example in a .term at the command line, you could type "open" to get an editor tab.

You can compile and run the file from the command line, but I think you may have already have done that. A CoCalc .term is a bash session into an Ubuntu container where java runtime is already installed. More info at the CoCalc wiki: (

Hal Snyder gravatar imageHal Snyder ( 2018-02-14 04:23:54 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-02-14 04:30:26 +0200

William Stein2 gravatar image
  1. Your Java code is working fine. It just happens to output some messages when running.

If you change line 5 to

System.out.println("ANSWER: " + istPalindrom(warray));"

you will see more clearly what the output is and that it is the output.

  1. Syntax highlighting:

Is there a way to enable the edditor to recognise java use some highlights

The editor works fine and highlights the java code properly. I don't know why you would think it doesn't. That said, the share serve evidently does NOT properly syntax highlight anything (what you linked to above), which is a bug that I've reported:

And: 3. Running Java code?

Your question is about running Java code, from what I understand, either in a Jupyter worksheet (.ipynb) or in a CoCalc worksheet (.sagews).

No - this has nothing to do with Jupyter or Sage or Sage worksheets. CoCalc has its own (secret, not advertised) side-by-side editor, where you type Java on one side, and when you save it compiles and runs it -- sort of like LaTeX.

edit flag offensive delete link more


Oh, good to know. This appears whenever one edits a text file with .java extension?

slelievre gravatar imageslelievre ( 2018-02-14 04:55:19 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-02-06 11:46:00 +0200

Seen: 692 times

Last updated: Feb 14 '18