Can’t use package javax.xml.bind from JAXB API 2.3.0

I’m trying to use classes from package javax.xml.bind (in jar file that I downloaded using maven : jaxb-api-2.3.0.jar) to convert between java object and XML file on eclipse using JDK9.

When I run my program, it throws an exception like that :

javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on 
module path or classpath. - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
Caused by: java.lang.ClassNotFoundException:com.sun.xml.internal.bind.v2.ContextFactory

I found out that package javax.xml.bind contained in module java.xml.bind on JDK System Libray is deprecated since JDK9.

It tooks me like hours to find a way to remove deprecated module and to start using jaxb-api-2.3.0.jar but nothing worked out.

Could you guys help me on this? Thank you in advance.

I got here Implementation of JAXB-API has not been found on module path or classpath same question but no answers so far.

Sudoku Solution Validator – for NxN Sudoku

Since the Sudoku can be any NxN size, I was wondering if there was a way to validate it using sum and a “hint”.
(for example, the 9×9 Sudoku: the hint is the black in the picture and the red is the solution “board”.)

What I started:

 public static boolean isSolution (int sqrtN, int [] [] hints, int [] [] board
     if (board.length = sqrtN * sqrtN && board[0].length = sqrtN*sqrtN ) // because I want to throw an IllegalExemption if the condition fails
            int n = board.length;
        int m = board[0].length;
        for (int x = 0; x<n ; x++;) {
            for (int)
        }

a regular Sudoku

Eclipse Oxygen JVM Error

I’m just getting back to java, and went and downloaded the latest Eclipse Oxygen. Once it’s all installed, I try to launch and get the following error dialogue.

Incompatible JVM

So I went and downloaded Java 8 and installed that. Once again I tried to open Eclipse. It still displays the exact same answer. Any idea on how to fix this?

Sending a string and file into InputStream

I’m trying to send a string which is the filename and then the file itself to a server. The string is being received and used to create the file by the server. However, there isn’t any data actually written into the file by the server.

I got the file transfer to work before I added the Writer’s (with the file names being hard-coded) to the server and client but now I can’t get both to work at the same time.

Client:

public class Client {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String fileName = sc.nextLine();
            System.out.println(fileName);
            try {
                File file = new File(fileName);
                Socket socket = new Socket("localhost", 15000);
                OutputStream os = socket.getOutputStream();
                Writer w = new OutputStreamWriter(os, "UTF-8");
                w.write(fileName);
                w.close();
                os.flush();
                byte[] mybytearray = new byte[(int) file.length()];
                BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
                bis.read(mybytearray, 0, mybytearray.length);
                os.write(mybytearray, 0, mybytearray.length);
                os.flush();
                os.close();
                socket.close();
            } catch (Exception e) { }
        }
        }
}

Server:

public class Server extends Thread {

    public static final int PORT = 15000;

    @Override
    public void run() {
        try {
            ServerSocket serverSocket = new ServerSocket(PORT);
            while (true) {
                Socket sock = serverSocket.accept();
                readFile(sock);
            }
        } catch (Exception e) {
        }
    }

    private void readFile(Socket socket) throws Exception {
        InputStream ois = socket.getInputStream();
        Reader r = new InputStreamReader(ois, "UTF-8");
        String filename = "";
        int ch = r.read();
        while(ch != -1) {
            filename += (char) ch;
            System.out.println(filename);
            ch = r.read();
        }

        r.close();
        System.out.println(filename);

        FileOutputStream fos = new FileOutputStream(filename);

        byte[] bytearr = new byte[4096];
        System.out.println("Reading file...");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        while ((ois.read(bytearr)) > 0) {
            bos.write(bytearr);
        }
        bos.close();
        System.out.println("Writing file complete...");
    }

    public static void main(String[] args) {
        new Server().start();
    }
}

Can I complete this in O(M log N) time?

So I am implementing Dijkstra’s algorithm and I am having trouble trying to reduce the runtime of it. Ideally, an O(M log N) runtime would be great.

Here is my code:

import static jdk.nashorn.internal.runtime.regexp.joni.Syntax.Java;

import java.util.Scanner;

public class Dijkstra {
  public static void main(String[] args) {

     int [][] A = new int[50010][60];
     int [][] W = new int[50010][60];
     int []   deg = new int[50010];


     int N, M, S;

     Scanner scan = new Scanner(System.in);
     N = scan.nextInt(); // # cities
     M = scan.nextInt(); // # train routes
     S = scan.nextInt(); // capital city
     // System.out.println(N + " " + M + " " + S);


     for(int i = 1; i <=N; ++i) {
       deg[i] = 0;  // initialize the degree of each vertex to 0
     }

     for(int i = 1; i <= M; ++i) {
       int u, v, w;
       u = scan.nextInt(); // origin
       v = scan.nextInt(); // destination
       w = scan.nextInt(); // # days
       // System.out.println(u + " " + v + " " + w);
       A[u][deg[u]] = v; // adding an edge (u,v) to the graph
       W[u][deg[u]] = w; // set its weight to w
       deg[u]++; // increase degree of vertex u by 1
     }

     //for(int i = 1; i <= N; ++i) {
     //  System.out.println("vertex:" + i + "'s neighbors");
     //  for(int j = 0; j < deg[i]; ++j) {
     //    System.out.println(A[i][j] + " " + W[i][j]);
     //  }
     //}

     // compute distance from U to S by Dijkstra's algorithm
     // Dijkstra's algorithm
     for(int U = 1; U <= N; ++U) {

       // initialization
       int[] visited = new int[50010];
       int[] dist = new int[50010];
       for(int V = 1; V <= N; ++V) {
         dist[V] = 100000000;
         visited[V] = 0;
       }

       // actual algorithm
       dist[U] = 0;
       for(int k = 1; k <= N; ++k) {
         // repeat the following N times

         //find an unvisited vertex with minimum distance
         int min = 100000000;
         int minVertex = 1;
         for(int i = 1; i<=N; ++i) {
           if(visited[i] == 0 && dist[i] < min) {
             min = dist[i];
             minVertex = i;
           }
         }

         visited[minVertex] = 1;
         // relax the edges that are adjacent to minVertex to update the           shortest path distance to
         // neighbors of minVertex

         for(int j = 0; j<deg[minVertex]; ++j) {
           // A[minVertex][j] is the j-th neighbor of minVertex
           // W[minVertex][j] is the weight of the corresponding edge
           int newDist = dist[minVertex] + W[minVertex][j];
           if (newDist < dist[A[minVertex][j]]) {
             dist[A[minVertex][j]] = newDist;
           }
         }


       }

       if(dist[S] == 100000000) {
         System.out.print("-1 ");
       }
       else {
         System.out.print(dist[S] + " ");
       }


     }

     System.out.println("");

   }


 }

I am having trouble trying to make it run in O(M log N) time. I know I have to implement heaps somewhere, but I’m not sure where.

Any help would be much appreciated.