asdru
asdru
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/22/2024 in #java-help
make github actions build artifact public
https://github.com/asdru22/Game2D/actions/runs/12453995171 i have a jar that is built that i can download. however, only i can download it. how can i change it so that anyone can download it?
25 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 12/19/2024 in #java-help
build javaFX jar from github via maven
maven.yml:
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '22'
distribution: 'oracle'
- run: mvn --batch-mode --update-snapshots verify
- run: mkdir staging && cp target/*.jar staging
- uses: actions/upload-artifact@v4
with:
name: Runnable Jar
path: staging`
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: '22'
distribution: 'oracle'
- run: mvn --batch-mode --update-snapshots verify
- run: mkdir staging && cp target/*.jar staging
- uses: actions/upload-artifact@v4
with:
name: Runnable Jar
path: staging`
Error: Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.4.2:jar (default-jar) on project QuizApp: Error assembling JAR: Could not create modular JAR file. The JDK jar tool exited with 1 -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Error: Process completed with exit code 1.
Error: Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:3.4.2:jar (default-jar) on project QuizApp: Error assembling JAR: Could not create modular JAR file. The JDK jar tool exited with 1 -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Error: Process completed with exit code 1.
7 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 10/24/2024 in #java-help
Optimizing draw function for texured triangle
https://github.com/asdru22/3D-Graphics/blob/rasterization/src/main/java/geom/Triangle.java My current implementation basically implements a rasterization algorithm from scratch, which isn't very efficent. But i don't know how i would otherwise make a triangles texture rotate with it
20 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 9/19/2024 in #java-help
scanner blocking thread close
in a project im working on i have a client with a sender and receiver thread. When the server send the quit command im also sending the clients the "quit" message which should intterupt their sender and receiver threads. The receiver ends just fine but the sender (that has the scanner) is stuck waiting for the next line. What's the appropriate way to handle this? i tried closing the senders' scanner in the receiver among other things but nothing worked
24 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 9/16/2024 in #java-help
keeping track of clients connected to server
i have a server class that implements the runnable method, and i want to keep track of the clients connected to it so i can disconnect all of them via server class method. I've seen that a common practise is to use clientHandlers that are Runnable so that each client can run concurrently with the others, but i still dont get how to store the connected client object to the server (if its even possible)
5 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 8/9/2024 in #java-help
convert n-tree to dictionary based on depth
public Map<Integer, List<Integer>> toDict() {

Map<Integer, List<Integer>> dict = new HashMap<>();
Queue<Node> queue = new LinkedList<>();
queue.add(root);
int depth = 0;

while (!queue.isEmpty()) {
int levelSize = queue.size();
List<Integer> currentLevel = new ArrayList<>();

for (int i = 0; i < levelSize; i++) {
Node node = queue.poll();
currentLevel.add(node.getValue());

// Add all children of the current node to the queue
for (Node child : node.children) {
queue.add(child);
}
}
dict.put(depth, currentLevel);
depth++;
}
return dict;
}
public Map<Integer, List<Integer>> toDict() {

Map<Integer, List<Integer>> dict = new HashMap<>();
Queue<Node> queue = new LinkedList<>();
queue.add(root);
int depth = 0;

while (!queue.isEmpty()) {
int levelSize = queue.size();
List<Integer> currentLevel = new ArrayList<>();

for (int i = 0; i < levelSize; i++) {
Node node = queue.poll();
currentLevel.add(node.getValue());

// Add all children of the current node to the queue
for (Node child : node.children) {
queue.add(child);
}
}
dict.put(depth, currentLevel);
depth++;
}
return dict;
}
I wrote this function to convert a tree into a dictionary where the depth is mapped to the nodes on that depth (i.e. 0->root) is there a better way to do this?
5 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 8/7/2024 in #java-help
isometric tile setup
No description
26 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 5/4/2024 in #java-help
Filling array with same object reference
playerParty[0] = new PlayerParty(new Vector2D(screenCenter.x-100,screenCenter.y),
new PlayableEntity[]{
PlayableEntity.getCharacter(PlayableEntity.Characters.PLAYER,this),
PlayableEntity.getCharacter(PlayableEntity.Characters.PLAYER,this),
PlayableEntity.getCharacter(PlayableEntity.Characters.PLAYER,this),
PlayableEntity.getCharacter(PlayableEntity.Characters.PLAYER,this)
});
playerParty[0] = new PlayerParty(new Vector2D(screenCenter.x-100,screenCenter.y),
new PlayableEntity[]{
PlayableEntity.getCharacter(PlayableEntity.Characters.PLAYER,this),
PlayableEntity.getCharacter(PlayableEntity.Characters.PLAYER,this),
PlayableEntity.getCharacter(PlayableEntity.Characters.PLAYER,this),
PlayableEntity.getCharacter(PlayableEntity.Characters.PLAYER,this)
});
get characters returns this return new PlayableEntity(gamePanel, "player",new Stats(100,20)); i thought this would make the playable entities inside of the array different intances of the same object, but for some reason all the changes i make the one playable entities in the array are applied to all other playable entities
29 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 5/3/2024 in #java-help
Build jar from maven project on github
No description
35 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 3/19/2024 in #java-help
cant build javafx project
Java FX Packager: Can't build artifact - fx:deploy is not available in this JDK this is the error i get but i dont understand what fx:deploy is
26 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 3/15/2024 in #java-help
Gson cannot be resolved to a type error randomly started appearing
public static Partita carica(int id) {
Gson gson = new Gson();
return gson.fromJson(Utili.leggiFileJson("partite", Integer.toString(id)), Partita.class);
}
public static Partita carica(int id) {
Gson gson = new Gson();
return gson.fromJson(Utili.leggiFileJson("partite", Integer.toString(id)), Partita.class);
}
i have this method that loads a json file into a class, which i dont exactly know it started throwing an error at this line Gson gson = new Gson(); despite me not touching that function or the Util function. The wierd part is that if i rewrite that function in a runnable class like
public static void main(String[] args) {
Gson gson = new Gson();
Partita p = gson.fromJson(Utili.leggiFileJson("partite", Integer.toString(25066)), Partita.class);
}
public static void main(String[] args) {
Gson gson = new Gson();
Partita p = gson.fromJson(Utili.leggiFileJson("partite", Integer.toString(25066)), Partita.class);
}
it works. so i can say its not an issue with imports or my util function
6 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 2/29/2024 in #java-help
modules randomly stopped working on intelliJ
No description
8 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 2/16/2024 in #java-help
return string that gets put in the text in a scene builder text label
No description
4 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 2/7/2024 in #java-help
javafx fxml file not found
package gioco.progettospacca.controller;

import gioco.progettospacca.classi.Partita;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;

import java.io.IOException;

public class HomeController {
@FXML
public void giocaPartita(ActionEvent actionEvent) {

}

public void EventoCreaPartita(ActionEvent actionEvent) throws IOException{
Parent root = FXMLLoader.load(getClass().getResource("LoginAdminView.fxml"));
Scene scene=new Scene(root);
Stage stage = (Stage)((Node)actionEvent.getSource()).getScene().getWindow();
stage.setTitle("Login amministratore");
stage.setScene(scene);
stage.show();

}

public void giocaTorneo(ActionEvent actionEvent) {
}

public void creaTorneo(ActionEvent actionEvent) {
}
}
package gioco.progettospacca.controller;

import gioco.progettospacca.classi.Partita;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;

import java.io.IOException;

public class HomeController {
@FXML
public void giocaPartita(ActionEvent actionEvent) {

}

public void EventoCreaPartita(ActionEvent actionEvent) throws IOException{
Parent root = FXMLLoader.load(getClass().getResource("LoginAdminView.fxml"));
Scene scene=new Scene(root);
Stage stage = (Stage)((Node)actionEvent.getSource()).getScene().getWindow();
stage.setTitle("Login amministratore");
stage.setScene(scene);
stage.show();

}

public void giocaTorneo(ActionEvent actionEvent) {
}

public void creaTorneo(ActionEvent actionEvent) {
}
}
i get an error saying that getClass().getResource("LoginAdminView.fxml") at line 22 is null i dont understand why since i have the same setup in the main class and that works. the only difference is that this class is in a subfolder and the main isnt. But i can't figure out what's wrong
28 replies
JCHJava Community | Help. Code. Learn.
Created by asdru on 5/22/2023 in #java-help
java.lang.ClassNotFoundException
I started getting this error regardless of what file i compiled, after a bit of research i managed to narrow down the issue to something wrong with my classpath in sistem variables, but hadn't had any luck fixing it
19 replies