Created
December 8, 2022 21:21
-
-
Save GavinRay97/bd7e36f3db9d3414b680d30a70f71f32 to your computer and use it in GitHub Desktop.
Revisions
-
GavinRay97 created this gist
Dec 8, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ # Makefile to compile and run Java sources manually # because JDK 20 Valhalla support is not yet available in IntelliJ IDEA JAVA_VERSION = 20 JAVAC = /home/user/downloads/jdk-20-vahalla-20-75/bin/javac JAVA = /home/user/downloads/jdk-20-vahalla-20-75/bin/java JAVA_COMPILE_OPTIONS = --enable-preview --release $(JAVA_VERSION) JAVA_OPTIONS = --enable-preview JAVA_MAIN_CLASS = org.example.Database JAVA_SOURCES = $(wildcard src/main/java/**/**/*.java) JAVA_CLASSES = $(patsubst src/main/java/%.java, target/classes/%.class, $(JAVA_SOURCES)) # Compile the Java source files compile: $(JAVA_CLASSES) $(info Java source files: $(JAVA_SOURCES)) $(info Java class files: $(JAVA_CLASSES)) # Run the Java main class run: compile $(JAVA) $(JAVA_OPTIONS) -cp target/classes $(JAVA_MAIN_CLASS) # Clean the target directory clean: rm -rf target # Compile the Java source files target/classes/%.class: src/main/java/%.java $(JAVAC) $(JAVA_COMPILE_OPTIONS) -d target/classes $< # Create the target directory target/classes: mkdir -p target/classes # Make the target directory a dependency of the Java class files $(JAVA_CLASSES): target/classes # Make the target directory a dependency of the compile target compile: target/classes # Ditto... clean: target/classes run: target/classes default: target/classes default: run This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ [user@MSI java-jdk20-valhalla]$ make run Java source files: src/main/java/org/example/Database.java src/main/java/org/example/PageLocation.java Java class files: target/classes/org/example/Database.class target/classes/org/example/PageLocation.class /home/user/downloads/jdk-20-vahalla-20-75/bin/java --enable-preview -cp target/classes org.example.Database Hello World! Page Location: PageLocation[databaseId=1, pageId=2] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ // ./src/main/java/org/example/Database.java package org.example; class Database { public static void main(String[] args) { var examplePageLocation = new PageLocation(1, 2); System.out.println("Hello World!"); System.out.println("Page Location: " + examplePageLocation); } } // ./src/main/java/org/example/PageLocations.java package org.example; public value record PageLocation(int databaseId, int pageId) {}