1 files modified
5 files renamed
11 files added
| New file |
| | |
| | | FROM openjdk:25-ea-18-slim |
| | | |
| | | # Install tools (esempio: Maven) |
| | | RUN apt-get update && \ |
| | | apt-get install -y maven git curl unzip && \ |
| | | rm -rf /var/lib/apt/lists/* |
| | | |
| | | # Crea utente vscode (richiesto per VS Code Dev Container) |
| | | RUN useradd -ms /bin/bash vscode && echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers |
| | | |
| | | # Imposta la directory di lavoro |
| | | WORKDIR /workspace |
| | | |
| | | # Imposta utente vscode |
| | | USER vscode |
| | | |
| | | ENV JAVA_HOME=/usr/local/openjdk-25 |
| | | ENV PATH=$JAVA_HOME/bin:$PATH |
| New file |
| | |
| | | { |
| | | "name": "Java Dev Container", |
| | | "dockerComposeFile": "docker-compose.yml", |
| | | "service": "java-dev", |
| | | "workspaceFolder": "/workspace", |
| | | "customizations": { |
| | | "vscode": { |
| | | "settings": { |
| | | "terminal.integrated.defaultProfile.linux": "bash" |
| | | }, |
| | | "extensions": [ |
| | | "vscjava.vscode-java-pack", // Java Extension Pack |
| | | "pivotal.vscode-spring-boot", // Spring support (opzionale) |
| | | "test-editor.test-editor", // Supporto ai test (opzionale) |
| | | "redhat.java", // Supporto al linguaggio Java |
| | | "dotjoshjohnson.xml" // XML Tools |
| | | ] |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | services: |
| | | java-dev: |
| | | build: |
| | | context: . |
| | | dockerfile: Dockerfile |
| | | container_name: java-dev |
| | | volumes: |
| | | - ..:/workspace:cached |
| | | tty: true |
| | | command: sleep infinity |
| | | |
| | |
| | | /nbdist/ |
| | | /.nb-gradle/ |
| | | |
| | | ### VS Code ### |
| | | .vscode/ |
| | | |
| | | ### intellij ### |
| | | .idea/ |
| | | |
| | | ### Mac OS ### |
| | | .DS_Store |
| | | .DS_Store |
| | | |
| | | target/ |
| New file |
| | |
| | | { |
| | | // ✅ Salvataggio automatico dopo una pausa di 1 secondo |
| | | "files.autoSave": "afterDelay", |
| | | "files.autoSaveDelay": 1000, |
| | | |
| | | // ✅ Mostra tutte le cartelle espanse (disattiva la "compattazione" nel file explorer) |
| | | "explorer.compactFolders": false, |
| | | |
| | | // (Facoltativo) ✅ Imposta il linguaggio di default per nuovi file senza estensione |
| | | "files.defaultLanguage": "java", |
| | | |
| | | "[java]": { |
| | | "editor.defaultFormatter": "redhat.java", |
| | | "editor.formatOnSave": true |
| | | }, |
| | | |
| | | // ✅ Abilita linting e suggerimenti Java |
| | | "java.errors.incompleteClasspath.severity": "warning", |
| | | "java.configuration.checkProjectSettingsExclusions": false, |
| | | "java.configuration.updateBuildConfiguration": "automatic", |
| | | "java.import.gradle.enabled": false, |
| | | "java.import.maven.enabled": true, |
| | | |
| | | // (Facoltativo) ✅ Rendi visibili anche i file nascosti (come .gitignore, ecc.) |
| | | "files.exclude": { |
| | | "**/.git": false, |
| | | "**/.DS_Store": true |
| | | } |
| | | } |
| New file |
| | |
| | | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
| | | <modelVersion>4.0.0</modelVersion> |
| | | |
| | | <groupId>com.example</groupId> |
| | | <artifactId>java-dev-container-project</artifactId> |
| | | <version>1.0-SNAPSHOT</version> |
| | | <packaging>jar</packaging> |
| | | |
| | | <properties> |
| | | <maven.compiler.source>25</maven.compiler.source> |
| | | <maven.compiler.target>25</maven.compiler.target> |
| | | </properties> |
| | | |
| | | <dependencies> |
| | | <!-- Add your project dependencies here --> |
| | | <dependency> |
| | | <groupId>org.junit.jupiter</groupId> |
| | | <artifactId>junit-jupiter</artifactId> |
| | | <version>5.10.0</version> |
| | | <scope>test</scope> |
| | | </dependency> |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <plugins> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-compiler-plugin</artifactId> |
| | | <version>3.8.1</version> |
| | | <configuration> |
| | | <source>25</source> |
| | | <target>25</target> |
| | | </configuration> |
| | | </plugin> |
| | | |
| | | <!-- Plugin per eseguire i test --> |
| | | <plugin> |
| | | <groupId>org.apache.maven.plugins</groupId> |
| | | <artifactId>maven-surefire-plugin</artifactId> |
| | | <version>3.2.5</version> |
| | | </plugin> |
| | | </plugins> |
| | | </build> |
| | | </project> |
| New file |
| | |
| | | public class DivisorPattern { |
| | | public static void main(String[] args) { |
| | | int limite = Integer.parseInt(args[0]); |
| | | |
| | | for (int i = 1; i <= limite; i++) { |
| | | for (int j = 1; j <= i; j++) { |
| | | if (i % j == 0) { |
| | | System.out.print("* "); |
| | | } else { |
| | | System.out.print(" "); |
| | | } |
| | | } |
| | | System.out.println(); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | public class Main { |
| | | public static void main(String[] args) { |
| | | System.out.println("Hello, World!"); |
| | | } |
| | | } |
| New file |
| | |
| | | public class NumeroPrimo { |
| | | public boolean isPrimo(int numero) { |
| | | if (numero <= 1) { |
| | | return false; |
| | | } |
| | | if (numero % 2 == 0) { |
| | | return false; |
| | | } |
| | | for (int i = 3; i <= Math.sqrt(numero); i += 2) { |
| | | if (numero % i == 0) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | NumeroPrimo np = new NumeroPrimo(); |
| | | |
| | | int limite = Integer.parseInt(args[0]); |
| | | |
| | | long startTime = System.nanoTime(); |
| | | int conta = 1; |
| | | for (int i = 3; i <= limite; i += 2) { |
| | | if (np.isPrimo(i)) { |
| | | System.out.println(conta + " " + i); |
| | | conta++; |
| | | } |
| | | } |
| | | |
| | | long endTime = System.nanoTime(); // ⏱️ Fine |
| | | |
| | | long duration = endTime - startTime; // in nanosecondi |
| | | System.out.println("Tempo di esecuzione: " + (duration / 1_000_000) + " ms"); |
| | | } |
| | | } |
| New file |
| | |
| | | public class PowerOfTwo { |
| | | public static void main(String[] args) { |
| | | int limite = Integer.parseInt(args[0]); |
| | | |
| | | int conta = 1; |
| | | for (int i = 1; i <= limite; i++) { |
| | | int potenza = i * i; |
| | | if (potenza <= limite) { |
| | | System.out.println(conta + " " + potenza); |
| | | conta++; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| New file |
| | |
| | | public class TenHello { |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | System.out.println("Hello, World! " + "1st"); |
| | | System.out.println("Hello, World! " + "2sd"); |
| | | System.out.println("Hello, World! " + "3rd"); |
| | | |
| | | for (int i = 4; i <= 10; i++) { |
| | | System.out.println("Hello, World! " + i + "th"); |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | |
| | | import org.junit.jupiter.api.Test; |
| | | import static org.junit.jupiter.api.Assertions.*; |
| | | |
| | | public class NumeroPrimoTest { |
| | | |
| | | @Test |
| | | void testPrimo1() { |
| | | NumeroPrimo primo = new NumeroPrimo(); |
| | | assertEquals(false, primo.isPrimo(1)); |
| | | } |
| | | |
| | | @Test |
| | | void testPrimoNegativo() { |
| | | NumeroPrimo primo = new NumeroPrimo(); |
| | | assertEquals(false, primo.isPrimo(-101)); |
| | | } |
| | | |
| | | @Test |
| | | void testSomma() { |
| | | NumeroPrimo primo = new NumeroPrimo(); |
| | | assertEquals(true, primo.isPrimo(3)); |
| | | } |
| | | |
| | | @Test |
| | | void testSommaNegativi() { |
| | | NumeroPrimo primo = new NumeroPrimo(); |
| | | assertEquals(false, primo.isPrimo(4)); |
| | | } |
| | | } |