1

In my javafx application I want to display math equations using technology MathJax with JavaFX's WebView. I have loaded the application in my homepage (in Greek). The problem I have is that when I download the jar file and run it, everything is ok! But when I run the application from inside browser the equation is not displayed properly: stand alone and in-browser

The code I use is

package webmath;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class WebMath extends Application {

@Override
public void start(Stage primaryStage) {

    WebView webView = new WebView();
    String htmlFile = "info.html";
    webView.getEngine().load(WebMath.class.getResource(htmlFile).toExternalForm());

    StackPane root = new StackPane();
    root.getChildren().add(webView);
    Scene scene = new Scene(root, 300, 250);

    primaryStage.setTitle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();
}

public static void main(String[] args) {
    launch(args);
}

}

and the containts of the html file is

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">               
    <script type="text/javascript"
            src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
    </script>

    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
    </script>         
    <script type="text/x-mathjax-config">
        MathJax.Hub.Config({showMathMenu: false});
    </script>  

</head>
<body >       
    <p>text text text text text...</p>
    <p>begin equation:</p>

    \begin{equation}\label{eq1}\tag{1}
        x = \frac{\sqrt{b^2 - 4ac}}{2a}
    \end{equation}

    <p>equation end.</p>
    <p>text text text text text...</p>
</body>

I can't understand what's going wrong. What I have to do so that the application runs good from inside the browser?

Thanks in advance.

0 Answers0