Gephi - Yash-777/SteamingServlet GitHub Wiki

Gephi - The Open Graph Viz Platform

Gephi is an open-source network analysis and visualization software package written in Java on the NetBeans platform.

The Gephi Toolkit project package essential modules (Graph, Layout, Filters, IO…) in a standard Java library, which any Java project can use for getting things done. The toolkit is just a single JAR that anyone could reuse in new Java applications and achieve tasks that can be done in Gephi automatically, from a command-line program for instance. The ability to use Gephi features like this in other Java applications boost possibilities and promise to be very useful.


Gephi runing jar servlet
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/gephi/jar")
public class HttpRequest extends HttpServlet {
    private static final long serialVersionUID = 1L;
    static String newClient = "cmd.exe /c start java -jar ";
    static String jarLocation = "D:\\JarFiles\\LearnJava.jar";
    
    public void commandsOfOS(String command) {
        try {
            Process process = Runtime.getRuntime().exec( newClient+command );
            InputStream inputStream = process.getInputStream();
            
            SubProcessThread inputConsumer = new SubProcessThread( inputStream, true );
            inputConsumer.start();
            
            int status = process.waitFor();
            System.out.println("Exited with status: " + status);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("=== GET ===");
        HttpRequestData.requestData(request);
        
        commandsOfOS(jarLocation);
        
        PrintWriter writer = response.getWriter();
        writer.append("GET Served at: ").append(request.getContextPath());
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("=== POST ===");
        HttpRequestData.requestData(request);
        
        commandsOfOS(jarLocation);
        
        PrintWriter writer = response.getWriter();
        writer.append("POST Served at: ").append(request.getContextPath());
    }

}
⚠️ **GitHub.com Fallback** ⚠️