java – LWJGL GLFW hangs on native glfwInit call

For the past months I’ve been working on creating my own game engine for personal use in LWJGL using pieces here and there, especially from developer ThinMatrix’s rightfully credited code, to learn as much as I can while building it. Only recently there has been strange behavior happening when I launch the engine from IntelliJ for testing:

  • After about 6-10 individual times I click run, all subsequent runs suddenly take about 60 seconds for the window to appear.

  • Whenever I restart my PC this hanging resets and I have another 6-10 runs before it hangs everytime again.

  • I located the issue to glfwInit, more specifically at the call to the native method:

      @NativeType("int")
      public static boolean glfwInit() {
          long __functionAddress = Functions.Init;
          return invokeI(__functionAddress) != 0; // Right here
      }
    
  • I also noticed that this issue only started when I attempted to implement text support in my engine using the STBTrueType library. It was perfectly fine before that. I tried removing the TrueType code but it didn’t fix it.

Here’s a list of things I’ve tried:

  • Clearing my temp folder in case a buggy or corrupted file was present.
  • Recompiling and rebuilding the entire LWJGL jars twice.
  • Building glfw.dll from the GLFW sources and replacing the glfw.dll in the native jars with the former.
  • Reinstalling Java and actually upgrading JDK versions (from 13.0.2 to 14.0.2)
  • Switching IDEs even if I suspected it wouldn’t work.
  • Updating my NVIDIA drivers, and reinstalling them.

I’m quite confused as to what it could be, and I’d be more than happy to share code, thread dumps, or debug info if you deem it necessary. Here is the Github repository with the latest, “faulty” code (fault in quotes because I’m not too sure the code is the problem.)

Thank you very much for any guidance.

P.S: Please tell me if this is better asked in StackOverflow instead of here.

java – ¿Como Establecer cambios en activity dentro de un botón antes de que se ejecute un método?

Estoy ejecutando un metodo en un setOnClickListener pero quiero mostrar un ProgressBar y hacer cambios en textView inmediatamente cuando se da clic en el botón, pero lo hace al finalizar el método, ¿que puedo hacer?
este esmi codigo

         public void onClick(View v) {
             titulo.setText("Enviando..");
             contenido.setText("Enviando registro...");
             progress.setVisibility(View.VISIBLE);
             bandera = "true";
             AsyncTask.execute(new Runnable() {
                 @Override
                 public void run() {
                     enviar(position, nombre, email, telefonoCelular, telefonoCasa, facebook, twitter, observaciones, nombreFoto, DirFotoCredencialLocal, DirFotoCredencial);

                 }
             });
         }

java – Cómo evitar valores repetidos en barchart de reporte jaspersoft

tengo un problema al generar un reporte con varios registros de personas, en el cual pinto una grafica de scores tipo BarChart como este:

introducir la descripción de la imagen aquí

La gráfica esta en un detail band, ya que se debe pintar por cada persona que venga en los registros.

El problema está en que cuando son varios registros, las gráficas pintan el mismo valor para todas las personas, lo cual esta mal. Estoy usando jaspersoft studio 6.6 y spring boot

java – How do I volleyrequest to see if data does not exist in mysql table? I want to set an x drawable in an imageview if an entry does not exist

I am making an app that has users complete a survey. They are given a grade that is time based. This means if you complete the survey (called the monthly check in) within 5 days you get an A, 8 days you get a B, and so on.

Using Volley, I am able to determine the grade and set my drawable image to check. What I am struggling with is setting my drawable to X and the grade to 0 if the monthly check in has been missed. Right now, the activity only reads the information when it exists.

Can anyone see why this else if statement does not work (!object.toString().contains(“TimeofCompletion”) && today.isAfter(FGrade))? TimeofCompletion is a time stamped that is saved when the user completes the survey. If it doesn’t exist, it means the user didn’t complete the survey and gets an x and 0 grade if today is after F grade date.

I have put my java and php files below.

Java

 public void getCompletionDate1() {


        sessionManager = new SessionManager(this);
        sessionManager.checkLogin();
        final ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setMessage("Loading...");
        progressDialog.show();
        //StringRequest stringRequest = new StringRequest(Request.Method.POST,"http://10.0.2.2/readMCICompletion.php", new Response.Listener<String>(){
       StringRequest stringRequest = new StringRequest(Request.Method.POST, URL_ReadCompletionDate,
               new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        progressDialog.dismiss();
                        Log.i(TAG, response.toString());

                        try {
                            JSONObject jsonObject = new JSONObject(response);
                            String success = jsonObject.getString("success");
                            JSONArray jsonArray = jsonObject.getJSONArray("read");

                            if (success.equals("1")||success.equals("0")) {
                                for (int i = 0; i < jsonArray.length(); i++) {
                                    JSONObject object = jsonArray.getJSONObject(i);

                                    String MCIdate = object.getString("start_date").trim();

                                    org.threeten.bp.LocalDate MCIAvailable = org.threeten.bp.LocalDate.parse(MCIdate, dateFormatter);
                                    org.threeten.bp.LocalDate AGrade = MCIAvailable.plusDays(5);
                                    org.threeten.bp.LocalDate BGrade = MCIAvailable.plusDays(8);
                                    org.threeten.bp.LocalDate CGrade = MCIAvailable.plusDays(11);
                                    org.threeten.bp.LocalDate DGrade = MCIAvailable.plusDays(15);
                                    org.threeten.bp.LocalDate FGrade = MCIAvailable.plusDays(20);

                                    String DOC = object.getString("TimeofCompletion").trim();

                                    org.threeten.bp.LocalDate TOC = org.threeten.bp.LocalDate.parse(DOC, dateFormatter);
                                    DOC1.setText("Completed on " + DOC);
                                    int MCIGrade1Value;

                                  if (TOC.isBefore(AGrade)){
                                          MCIGrade1.setText("%100");
                                          MCIGrade1Value = 100;
                                          Drawable check;
                                          check = getResources().getDrawable(R.drawable.ic_cloud_done_black_24dp);
                                          warning1.setImageDrawable(check);
                                      } else if (TOC.isBefore(BGrade) && TOC.isAfter(AGrade)) {
                                          MCIGrade1.setText("%85");
                                          MCIGrade1Value = 85;
                                          Drawable check;
                                          check = getResources().getDrawable(R.drawable.ic_cloud_done_black_24dp);
                                          warning1.setImageDrawable(check);
                                      } else if (TOC.isBefore(CGrade) && TOC.isAfter(BGrade)) {
                                          MCIGrade1.setText("%75");
                                          MCIGrade1Value = 75;
                                          Drawable check;
                                          check = getResources().getDrawable(R.drawable.ic_cloud_done_black_24dp);
                                          warning1.setImageDrawable(check);
                                      } else if (TOC.isBefore(DGrade) && TOC.isAfter(CGrade)) {
                                          MCIGrade1.setText("%65");
                                          MCIGrade1Value = 65;
                                          Drawable check;
                                          check = getResources().getDrawable(R.drawable.ic_cloud_done_black_24dp);
                                          warning1.setImageDrawable(check);
                                      } else if (TOC.isAfter(DGrade)) {
                                          MCIGrade1.setText("%55");
                                          MCIGrade1Value = 55;
                                          Drawable check;
                                          check = getResources().getDrawable(R.drawable.ic_cloud_done_black_24dp);
                                      warning1.setImageDrawable(check);
                                    }else if (!object.toString().contains("TimeofCompletion") && today.isAfter(FGrade)){
                                        Drawable x;
                                        x = getResources().getDrawable(R.drawable.ic_clear_white_24dp);
                                        warning1.setImageDrawable(x);
                                        MCIGrade1Value = 0;
                                    }else {
                                      Drawable assignment;
                                      assignment = getResources().getDrawable(R.drawable.ic_assignment_black_24dp);
                                      warning1.setImageDrawable(assignment);
                                      MCIGrade1.setText("Grade");
                                      DOC1.setText("To be completed");
                                  }
                            }
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                            progressDialog.dismiss();

                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        progressDialog.dismiss();


                    }
                }) {
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> params = new HashMap<>();
                params.put("id", getId);
                return params;
            }

        };

        RequestQueue requestQueue = Volley.newRequestQueue(this);
        requestQueue.add(stringRequest);
    }

PHP

<?php

if ($_SERVER('REQUEST_METHOD')=='POST') {

    $id = $_POST('id');

    $conn = mysqli_connect("localhost", "root", "", "users");

    $sql = "SELECT u.start_date, m.TimeofCompletion FROM users_table AS u JOIN mci_table AS m ON u.id = m.id WHERE u.id = '$id'";
   // $sql = "SELECT mci_table.*, users_table.id, users_table.start_date, users_table.end_date FROM mci_table JOIN users_table where  mci_table.id='$id' && mci_table.id=users_table.id ";

    $response = mysqli_query($conn, $sql);



    $result = array();
   $result('read') = array();

    if( mysqli_num_rows($response) === 1 ) {

        if ($row = mysqli_fetch_assoc($response)) {



               $h('start_date')        = $row('start_date') ;
                      $h('TimeofCompletion')        = $row('TimeofCompletion') ;






           array_push($result("read"), $h);

                       $result("success") = "1";
                       echo json_encode($result);
                  }

             }

           }else {

               $result("success") = "0";
               $result("message") = "Error!";
               echo json_encode($result);

               mysqli_close($conn);
           }

           ?>

mysql – Java SQL Query – value pair

I wish to select data where two columns are in a set of pairs.

I have a MySQL query that works:

SELECT t.whatever 
FROM t 
  JOIN 
    ( VALUES (val1a, val2a), (val1b, val2b), ...) AS x (col1, col2)
      ON  x.col1 = t.col1
      AND x.col2 = t.col2 ;

But when I try to use it in Java with parameters I can’t get it working. This is what I’ve tried:

@Query(value = "SELECT t.whatever FROM t JOIN (VALUES (?1) AS x (col1, col2) ON  x.col1 = t.col1 AND x.col2 = t.col2 ;", nativeQuery = true)
    List<Whatever> findByPair(List<List<String>> PairString);

I get the following error: ‘x’ has more columns than were specified in the column list

Where PairString is a list of lists of strings such as:

((val1a, val2a), (val1b, val2b), (val1c, val2c), (val1d, val2d))

java – Agradeço qualquer ajuda

A pouco tempo venho estudando Java, e agora estou tentando fazer um Render 3D simples, mas na primeira linha recebo do Eclipse o erro : “Cannot infer type arguments for ArrayList<>”. Como resolve-lo?

List tris = new ArrayList<>();
        tris.add(new Triangle(new Vertex(100, 100, 100),
                              new Vertex(-100, -100, 100),
                              new Vertex(-100, 100, -100),
                              Color.WHITE));
        tris.add(new Triangle(new Vertex(100, 100, 100),
                              new Vertex(-100, -100, 100),
                              new Vertex(100, -100, -100),
                              Color.RED));
        tris.add(new Triangle(new Vertex(-100, 100, -100),
                              new Vertex(100, -100, -100),
                              new Vertex(100, 100, 100),
                              Color.GREEN));
        tris.add(new Triangle(new Vertex(-100, 100, -100),
                              new Vertex(100, -100, -100),
                              new Vertex(-100, -100, 100),
                              Color.BLUE));

beginner – Tips on my LILO java code

I’ve been trying to learn java recently and I finally finish my first code. Any suggestions on where I can improve? Also, is it possible to send an argument to a class using something like an init function in python and are there any good and bad habits that I should keep in mind?

class LIFO {
    
    //Create an empty list with the lenght of the given size
    //Initialize our top value as 0
    int my_list() = new int(5);
    int top = 0;
    
    //Adds a value to the list
    //Add one to our top
    public void push(int data)
    {
        my_list(top) = data;
        top++;
    }
    
    //Removes the top value from the list
    //Substract one from our top
    public int pop()
    {
        int data;
        top--;
        data = my_list(top);
        my_list(top) = 0;
        return data;

    }

    //Prints our list
    public void show()
    {
        for(int n : my_list)
        {
            System.out.print(n + " ");
        }
    }
}

//Driver Class
class Main {
    public static void main(String args())
    {
        LIFO s = new LIFO();
        s.push(1);
        s.push(2);
        s.push(3);
        s.show();
        System.out.println("n" + s.pop() + " Popped from stack");
        s.show();
    

    }
}

Quien puede hacer este ejercicio en java?

Necesito alguien que puede hacer este programa en java porfavor, urgente

Ejercicio 1
Crear un programa con una clase llamada estudiante, la cual tendrá los
siguientes atributos: Nombre Alumno, edad, Nota Practica, Primer Parcial,
Segundo Parcial y Examen final. Luego ingresar por teclado un listado de
estudiantes y realizar el cálculo de la calificación final de cada uno.
Tomando en consideración que la calificación final es igual al (Promedio
Examen parcial + Nota Practica + Examen Final) entre 3. La calificación
final debe ser expresada en letras Ejemplo: 100 – 95 equivale a A, 85 – 94
equivale a B, etc.

Ejercicio 2
Utilizando el método de burbuja ordenar el listado de estudiante por edad
y calificación final.

Ejercicio 3
Mostar en pantalla el estudiante mas joven y con la calificación mas alta.

Ejercicio 4
Mostar el estudiante con la calificación mas baja y el estudiante con la
calificación mas alta.

java – Dúvida sobre a relaçao ManyToMany JPA

Olá, possuo duas classes na minha API, pokemon e type, e elas possuem uma relação ManyToMany entre si. Quando eu executo os métodos nos meus controllers para buscar todos os pokemons ou todos os types acaba gerando uma recursão infinita.

Depois de pesquisar um pouco vi que sempre que se usa um relacionamento bidirecional você precisa anotar um lado da relação para que ela seja ignorada na hora do jackson fazer a serialização. Porém após anotar o atributo da classe Type com @JsonIgnore, o meu método de buscar todos os Types não trás os pokemons correspondentes a cada type no json e o método de buscar todos os pokemons funciona corretamente.

Alguém teria uma solução para evitar a recursão infinita na serialização e ao mesmo tempo possibilitar que ambos os lados da relação consigam serializar os seus atributos?

Pokemon:

@Getter @Setter @NoArgsConstructor @AllArgsConstructor
@Entity
@Table(name="pokemons")
public class Pokemon implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    
    private String name;
    
    private String url;
    
    private String img;
    
    @ManyToMany
    @JoinTable(
        name = "pokemon_types",
        joinColumns = @JoinColumn(name = "pokemon_id"),
        inverseJoinColumns = @JoinColumn(name = "type_id"))
    private Set<Type> types;
    
}

Type:

@Setter @Getter @NoArgsConstructor @AllArgsConstructor
@Entity
@Table(name="types")
public class Type implements Serializable{

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    
    private String name;
    
    @JsonIgnore
    @ManyToMany(mappedBy = "types")
    Set<Pokemon> pokemons;

}

¿Por no se cambia los valores de mi array? /w Java, Eclipse

Lo que quiero conseguir es con el SET cambiar el valor de un dato en private y que después cuando lo quiera reabrir con un GET el dato este modificado.

private int()() map01 = {
        {1,1,1,1,1,1,1,1},
        {1,0,0,0,0,0,0,1},
        {1,0,5,0,1,0,0,1},
        {1,0,0,0,0,0,0,1},
        {1,1,1,1,1,1,1,1},      
};
public int()() getMap01() {
    return map01;
}
public void setMap01(int()() map) {
    this.map01 = map;
}