Skip to content

Instantly share code, notes, and snippets.

@trashgod
Last active April 18, 2023 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trashgod/c3e0fa8480b11f93b9ab08e597a45a5a to your computer and use it in GitHub Desktop.
Save trashgod/c3e0fa8480b11f93b9ab08e597a45a5a to your computer and use it in GitHub Desktop.
Version check
<!-- Minimal ant build file for VersionCheck -->
<!-- https://stackoverflow.com/q/71131137/230513 -->
<project name="VersionCheck" default="default" basedir=".">
<!-- set global properties for this build -->
<property name="proj" value="VersionCheck"/>
<property name="main" value="VersionCheck"/>
<property name="srcDir" value="."/>
<property name="buildDir" value="."/>
<property name="distDir" value="."/>
<property name="jversion" value="17"/>
<property name="version" value="1.0.0"/>
<property name="modulePath" value="/Users/Shared/javafx-sdk-17.0.6/lib"/>
<property name="modules" value="ALL-MODULE-PATH"/>
<!-- Initialize -->
<target name="init" description="Initialize the build process.">
<!-- Create a time stamp -->
<tstamp/>
</target>
<!-- Compile source files to class files -->
<target name="compile" depends="init" description="Compile the program.">
<mkdir dir="${buildDir}"/>
<javac srcDir="${srcDir}" destDir="${buildDir}" includeantruntime="false"
debug="on" source="${jversion}" target="${jversion}">
<compilerarg line="--module-path ${modulePath}"/>
<compilerarg line="--add-modules ${modules}"/>
</javac>
</target>
<!-- Build jar from classes -->
<target name="jar" depends="compile" description="Build a jar file.">
<jar destfile="${distDir}/${proj}.jar">
<manifest>
<attribute name="Main-Class" value="${main}"/>
</manifest>
<fileset file="build.xml"/>
<fileset file="${srcDir}/${main}.java"/>
<fileset file="${buildDir}/${main}.class"/>
</jar>
</target>
<!-- Run the program -->
<target name="run" depends="jar" description="Run the program.">
<java jar="${distDir}/${proj}.jar" fork="true">
<jvmarg line="--module-path ${modulePath}"/>
<jvmarg line="--add-modules ${modules}"/>
</java>
</target>
<!-- Run the program -->
<target name="test" depends="run" description="Test the program.">
<java jar="${distDir}/${proj}.jar" fork="true">
<arg line="${proj}.jar"/>
</java>
</target>
<!-- Clean up all build/dist/temp directories -->
<target name="clean" description="Clean the project.">
<delete dir="${buildDir}" includes="**/*.class"/>
<delete dir="${distDir}" includes="*.jar"/>
</target>
<!-- Default target -->
<target name="default" depends="clean, jar" description="Default clean and build.">
</target>
</project>
#!/bin/sh
JFX="--module-path /Users/Shared/javafx-sdk-17.0.6/lib --add-modules ALL-MODULE-PATH"
javac $JFX *.java && java $JFX VersionCheck
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
/**
* @see https://stackoverflow.com/q/11266997/230513
*/
public class VersionCheck extends Application {
@Override
public void start(Stage stage) {
stage.setTitle("VersionCheck");
BorderPane root = new BorderPane();
root.setBottom(createVersion());
stage.setScene(new Scene(root));
stage.show();
}
private Label createVersion() {
Label label = new Label(
System.getProperty("os.name")
+ " v" + System.getProperty("os.version")
+ "; Java v" + System.getProperty("java.version")
+ "; JavaFX v" + System.getProperty("javafx.runtime.version"));
label.setPadding(new Insets(8));
return label;
}
public static void main(String[] args) {
launch(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment