#using installDist .bat file (as compiled version) but it messes up file paths
1 messages ยท Page 1 of 1 (latest)
(Gtg now so ill check back in about 7 hrs)
What is not working anymore?
I'm trying to get it to run with the build.gradle dependencies but it doesn't work. Only works with the raw files which don't work when compiled into a jar file
with OpenCV
And do you get any error?
> Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve org.opencv:opencv:4.12.0.
Required by:
root project 'JavaMacroTool'
> No matching variant of org.opencv:opencv:4.12.0 was found. The consumer was configured to find a library for use during compile-time, compatible with Java 25, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally but:
- Variant 'releaseVariantReleaseApiPublication' declares a library for use during compile-time, and its dependencies declared externally:
- Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
- Other compatible attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about its target Java version (required compatibility with Java 25)
- Variant 'releaseVariantReleaseJavaDocPublication' declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its elements (required them preferably in the form of class files)
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about its target Java version (required compatibility with Java 25)
- Variant 'releaseVariantReleaseRuntimePublication' declares a library for use during runtime, and its dependencies declared externally:
```
- Other compatible attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about its target Java version (required compatibility with Java 25)
- Variant 'releaseVariantReleaseSourcePublication' declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its elements (required them preferably in the form of class files)
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about its target Java version (required compatibility with Java 25)```
* Try:
> No matching variant errors are explained in more detail at https://docs.gradle.org/9.1.0/userguide/variant_model.html#sub:variant-no-match.
> Review the variant matching algorithm at https://docs.gradle.org/9.1.0/userguide/variant_attributes.html#sec:abm_algorithm.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.
BUILD FAILED in 28s
1 actionable task: 1 executed
sorry for the mutliple files it wasn't letting me send the error as a .txt (laptop hella buggy) and was to big to send as one
Why do you have your opencv dependency declared 3 times with different scopes? implementation should also cover the other 2.
It does not seem to be able to resolve the dependencies as the dependency list in your image also shows. So for now try to only use implementation to see if ti solves the issue
because i don't know how it works. I started of trying only implementation and it gave me the same exact error
i tried looking up some videos on how dependancys work and tried stuff but i get that same error
weird thing is, i got it working with using the dll and jar file for openCV but not the other way
It seems like it tries to use the android binaries, or something like that. Try using that implementation 'org.opencv:opencv:4.12.0@jar'
Otherwise you can also use the downloaded jar file with implementation files('libs/opencv-4.12.0.jar')
Just copy to jar into the project
I did the libs/files and it didn't load, i thought it was a gradle thing but if its not ill try fix that
(when i get the chance)
also, how do i use the build.gradle to choose which file it runs when it builds the jar
like what file is called so it doesn't just perform nothong @west smelt
You don't.
If you want to continue using gradle I suggest you to switch to the Kotlin DSL. Rename you gradle build file to build.gradle.kts. It has a slightly different syntax but is much better in terms of usability. Then add the distribution plugin which builds you a proper distribution of you app. Then you just need to execute a bat/shell script to run your application
ok, ill try
its only build.gradle that needs to be change to build.gradle.kts right?
yes
ok
plugins {
id("java")
id("application")
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation(files("libs/opencv-4120.jar"))
}
tasks.test {
useJUnitPlatform()
}
application {
mainClass.set("org.robot.macroFunctions")
}
tasks.jar {
manifest {
attributes(
"Main-Class" to "org.robot.macroFunctions"
)
}
}
i got this, it doesn't give any errors but when i create a jar file it, the jar file does nothing when run
so is there any way to run a .jar and see if there is anything wrong with it?
Detected code, here are some useful tools:
You don't need the tasks.jar part, that's what the application plugin does and why you specify it in the application block. If you have a module-info then you can add to application blockmainModule.set(modulename) as well as applicationDefaultJvmArgs.set(listOf())
The try gradlew run
alright, i ran this and then jar (under the build folder tasks in gradle):
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed module (file:/C:/Users/Parad/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/native-platform-0.22-milestone-28.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled
> Task :compileJava
Note: C:\Users\Parad\Downloads\java-macro\pytorchmacro\src\main\java\org\robot\macroFunctions.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :run
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by org.robot.macroFunctions in an unnamed module (file:/C:/Users/Parad/Downloads/java-macro/pytorchmacro/build/classes/java/main/)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled
OpenCV version:4.12.0
debugMode:enabled
teamsCallLoop Activated
[Incubating] Problems report is available at: file:///C:/Users/Parad/Downloads/java-macro/pytorchmacro/build/reports/problems/problems-report.html
BUILD SUCCESSFUL in 33s
3 actionable tasks: 2 executed, 1 up-to-date
Consider enabling configuration cache to speed up this build: https://docs.gradle.org/9.1.0/userguide/configuration_cache_enabling.html
PS C:\Users\Parad\Downloads\java-macro\pytorchmacro>
but it still makes a .jar that doesn't do anything or give any error or anything
Detected code, here are some useful tools:
for context it creates this UI, but only when running macroFunctions.java and not working with the .jar file
My bad, I think application plugin doesn't inject mainClass into the jar, so ignore that advice.
You're talking about double clicking your jar file and it not working?
That's related to your system not associating it with java.
If you double-click on a jar file, and your Java application does not start, your .jar association has been hijacked. You can fix the problem with Jarfix. https://johann.loefflmann.net/en/software/jarfix/index.html
Jarfix
yup
did both double click and this, which shows java so it should run with that
C:\Users\Parad>java -version
java version "25" 2025-09-16 LTS
Java(TM) SE Runtime Environment (build 25+37-LTS-3491)
Java HotSpot(TM) 64-Bit Server VM (build 25+37-LTS-3491, mixed mode, sharing)
and its java 25
When you click on a .txt file, a program opens up. How does windows know which program to open up. There is a list it maintains that ASSOCIATES file name endings with installed programs (e.g. wordpad, java)
I guess this jarfix program programmatically does this for you but somewhere in windows settings you can get that list.
i just tested another jar file for a public program and it worked, so its def the file itself
not that the file isn't using java correctly ( i think)
So it has the mainclass in the manifest? Is this the only jre you have installed.
Try that jarfix thing, it must work since it's a tag on this server.
Or you can make a standalone
jarfix?
I've seen people here say it works
dis
k
might be that it's currently only associated with older java runtime you have installed and thus crashes out if it needs java25 or some other newer java.
Is this javafx?
Tried jarfix and still nothing
Is this javafx?
Im not using any javafx
i double checked and there are 0 mentions of javafx in my entire program so i think im alright
When you go into Settings->System-> type defaultApps in search bar.->scroll down and click on "choose default apps by file type"
window settings that is.
is there an entry for .jar?
if you click on it does to go to it's location?
nah it does this
Yea, it's only showing apps installed through windows. Like an installer.
Do you have another jdk/jre like 1.8 installed in windows
Which would be this one it refers to?
found a 21.0.8 that wouldn't show anywhere else
(c) Microsoft Corporation. All rights reserved.
C:\Users\Parad>where java
C:\Program Files\Common Files\Oracle\Java\javapath\java.exe
C:\Users\Parad>java -version
java version "25" 2025-09-16 LTS
Java(TM) SE Runtime Environment (build 25+37-LTS-3491)
Java HotSpot(TM) 64-Bit Server VM (build 25+37-LTS-3491, mixed mode, sharing)
C:\Users\Parad>
Detected code, here are some useful tools:
That's how we used to do it in the old days, modify the registry but I think they disallowed setting file associations that way in windows 10.
Actually I think I had a program to do it.
I looked on mine and I don't have a .jar association on this 13yr old install.
You can try jpackage, to make a .exe
whats jpackage?
gradlew jpackage
is this built in or a plugin that i need to put in gradle.build.kts?
FAILURE: Build failed with an exception.
- What went wrong:
Task 'jpackage' not found in root project 'JavaMacroTool'.
Due to the JVM and bytecode as intermediate execution stage, turning a Java application into a standalone executable (exe, msi, deb, rpm, dmg, pkg) is not trivial.
However, there exist various tools to do the job. They mostly differ in the details of the solution they create and hence also in their purpose:
- jpackage (the official tool) - creates an installer
- Launch4J - creates a wrapper executable that unwraps on execution
- GraalVM - attempts to create an actual native executable instead of wrappers or installers
This guide explains how to use jpackage, an official tool that is available in all JDKs since Java 16. The tool creates an installer for the application, so the end-user will get an executable that guides them through a setup where they can select installation path and tweak other settings, finally resulting in the application being installed on the machine (with a proper uninstaller, desktop shortcuts, start menu entries, ...): https://i.ibb.co/8Kn20fS/2V5ovUu.png
As an example, suppose you have a fat jar of your application called HelloWorld.jar, with a main class called Main. Put the jar into a dedicated release folder for simplicity. Execute the following command and you have an installer for your application in a folder called installer:
jpackage --input "release" --dest "installer" --main-class "Main" --main-jar "HelloWorld.jar" --name "HelloWorld" --win-dir-chooser --win-menu --win-shortcut --type exe
See the official documentation for more information on the available commands and for other operating systems:
- https://docs.oracle.com/en/java/javase/16/jpackage/packaging-overview.html#GUID-C1027043-587D-418D-8188-EF8F44A4C06A
- https://docs.oracle.com/en/java/javase/16/docs/specs/man/jpackage.html
Here is an example for a more complex setup which also associates file endings to the application, has a custom icon and more: https://pastebin.com/cfzqSKnW
ty
I've only ever tried in a javafx gradle build. There was no specific plugin required but...
ok I looked at that project it was using this beryx plugin.
plugins {
java
application
id("org.openjfx.javafxplugin") version "0.1.0"
id("org.beryx.jlink") version "3.1.2"
}
With this jlink block
jlink {
imageZip.set(layout.buildDirectory.file("/distributions/app-${javafx.platform.classifier}.zip"))
options.set(listOf("--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages"))
launcher {
name = "app"
}
}
and jpackage makes an .exe in the build folder. Actually don't need that jlink block I think.
should i use this?
is it like some extension to jpackage or its own thing
yea, try it. put that plugin in the plugins block like I had above and then skip the jlink block and just try gradlew jpackage
when i build i get this with both jpackage and jlink:
An exception occurred applying plugin request [id: 'org.beryx.jlink', version: '3.1.2']
> Failed to apply plugin 'org.beryx.jlink'.
> Cannot add task 'jpackage' as a task with that name already exists.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.
BUILD FAILED in 198ms
when i do without jpackage and only jlink i get:
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.panteleyev.jpackageplugin:org.panteleyev.jpackageplugin.gradle.plugin:1.7.6.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/panteleyev/jpackageplugin/org.panteleyev.jpackageplugin.gradle.plugin/1.7.6/org.panteleyev.jpackageplugin.gradle.plugin-1.7.6.pom
Required by:
root project 'JavaMacroTool'
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
id("java")
id("application")
id("org.panteleyev.jpackageplugin") version "1.7.6"
id("org.beryx.jlink") version "3.1.2"
}```
and
```plugins {
id("java")
id("application")
id("org.beryx.jlink") version "3.1.2"
}```
no get rid of that panetleyev one.
doing that gives this error (like shown above):
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.panteleyev.jpackageplugin:org.panteleyev.jpackageplugin.gradle.plugin:1.7.6.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/panteleyev/jpackageplugin/org.panteleyev.jpackageplugin.gradle.plugin/1.7.6/org.panteleyev.jpackageplugin.gradle.plugin-1.7.6.pom
Required by:
root project 'JavaMacroTool'
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
clean
you removed that panteleyev plugin?
yup
are you using intellij?
Is there a sync button you didn't hit?
yup forgot to do that
build still fails but it now shows other gradle commands
Like wix toolset or something like that?
wix toolset?
try clicking on jpackageImage
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.panteleyev.jpackageplugin:org.panteleyev.jpackageplugin.gradle.plugin:1.7.6.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/panteleyev/jpackageplugin/org.panteleyev.jpackageplugin.gradle.plugin/1.7.6/org.panteleyev.jpackageplugin.gradle.plugin-1.7.6.pom
Required by:
root project 'JavaMacroTool'
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
forgot abt dependancys lol
sorry abt that
build is fixed but jpackage command isn;t
> Error while evaluating property 'moduleName' of task ':prepareModulesDir'.
> Failed to query the value of extension 'jlink' property 'moduleName'.
> Cannot find module-info.java in [C:\Users\Parad\Downloads\java-macro\pytorchmacro\src\main\java]
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (Powered by Develocity).
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/9.1.0/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 6s
7 actionable tasks: 4 executed, 3 up-to-date
Detected code, here are some useful tools:
Ok, so you don't have a module-info.java file
right-click on your src/main/java in project view and choose New -> then module-info.java. See if it fills one out for you.
doesn't auto fill
I have ultimate intellij so not sure if same as what you ahve but it throws up a bar saying "Fill in module dependencies"
one sec
alt-enter should bring up a menu with that too
i think i missed something
or right click somewhere in module file and choose context actions
You should have a module-info file with at least module somename{} right?
by module-info.java do u mean in package module and under that info.java
bc module-info.java is "not a qualified name"
right click on that blue java folder icon, a menu comes up, Choose new-> you should see another menu I think, find module-info.java
so try jpackage or jpackageImage
requires opencv;
^```
so the file version is the only one that works, but i think this wants something extra or the other method of adding it that would always try use a android version
Detected code, here are some useful tools:
is it supposed to be requires org.opencv?
that doesn't work either
hmm, maybe it's that jar file dependency
implementation(files("libs/opencv-4120.jar"))
this one?
if i go back to that i get the same old error where it tries to find a android jar
> Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve org.opencv:opencv:4.12.0.
Required by:
root project 'JavaMacroTool'
> No matching variant of org.opencv:opencv:4.12.0 was found. The consumer was configured to find a library for use during compile-time, compatible with Java 25, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally but:
- Variant 'releaseVariantReleaseApiPublication' declares a library for use during compile-time, and its dependencies declared externally:
- Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, packaged as a jar
- Other compatible attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about its target Java version (required compatibility with Java 25)
- Variant 'releaseVariantReleaseJavaDocPublication' declares a component for use during runtime, and its dependencies declared externally:
It looks like you have to use a different dependency. (I asked chatgpt!)
implementation 'org.bytedeco:opencv:4.10.0-1.5.10'
implementation 'org.bytedeco:opencv-platform:4.10.0-1.5.10' // includes native binaries for all OSes
use that instead of the implementation 'org.opencv:opencv:4.12.0'
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.bytedeco:opencv-platform:4.10.0-1.5.10.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/bytedeco/opencv-platform/4.10.0-1.5.10/opencv-platform-4.10.0-1.5.10.pom
Required by:
root project 'JavaMacroTool'
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
maybe chat got the versions wrong, you can look it up.
// https://mvnrepository.com/artifact/org.bytedeco/opencv
implementation("org.bytedeco:opencv:4.11.0-1.5.12")
// https://mvnrepository.com/artifact/org.bytedeco/opencv-platform
implementation("org.bytedeco:opencv-platform:4.11.0-1.5.12")
Those are latest from june
it downloaded a bunch of stuff but still led to
requires org.opencv;
^```
Detected code, here are some useful tools:
so go back to just requires openvc
doesn't work either, tried that right after trying org. in front
I'm barely awake. remove it
i mean the issue is complicated
you have been the best help
tried that
should i just send the github and see if anyone else knows whats going on?
I meant the entire module-info.java file. Just rename it to schmodule-info.java and see ifyou can get a jar file that works on double click.
It was jpackage that wanted the module-info file
error: module declarations should be in a file named module-info.java
module JavaMacroTool.main {
^
i don't get what renaming is gonna do
Just so it's not recognized as module-info.java. move it outside of this workspace if you must.
not sure why they gave it a .java extension.
it can be double clicked but defaults to java 21, just like before
surely there must be some way to make it auto-run with 25 if possible
Does it need java25 though?
You downloaded java25 via intellij? I wonder if that jarfix relies on a JAVA_HOME setting.
yeah downloaded with intellij
i think this could work if i reinstall this way
(as u can see even the unistaller can't detect it)
echo %JAVA_HOME% in a cmd.exe
C:\Users\Parad>echo %JAVA_HOME%
%JAVA_HOME%
C:\Users\Parad>echo %JAVA_HOME%
%JAVA_HOME%
C:\Users\Parad>
Chat says you can run jarfix from cmd.exe and point to jdk not installed with msi.
jarfix.exe /k "C:\path\to\jdk-21\bin\javaw.exe"
I just accidentally posted some relavant info in chit-chat
Ability to associate filetype (.jar) is hidden at the bottom of the scroll
right click on teh jar file, open with, choose more apps
then scroll down all the way adn you'll see there is a link to choose a file directly (javaw.exe)
"Look for another app on this pc"
i see
i just gotta fix intellij because reinstalling java 25 just broke it even more
I have to go to bed, I hope one of those two things works.
yeah
thanks for all your help btw
got it to run with java 25 in cmd:
C:\Users\Parad>"C:\Program Files\Java\jdk-25\bin\java.exe" -jar "C:\Users\Parad\Downloads\java-macro\pytorchmacro\build\libs\JavaMacroTool-1.0-SNAPSHOT.jar" no main manifest attribute, in C:\Users\Parad\Downloads\java-macro\pytorchmacro\build\libs\JavaMacroTool-1.0-SNAPSHOT.jar
its missing main manifest attribute but i already have mainClass.set("org.robot.macroFunctions")
id("java")
id("application")
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation("org.bytedeco:opencv-platform:4.11.0-1.5.12")
}
tasks.test {
useJUnitPlatform()
}
application {
mainClass.set("org.robot.macroFunctions")
}
maybe the file location is wrong?
I haven't read the conversation since we talked yesterday. Why are you executing the jar instead of the distribution that is being built? Execute the gradle command installDist and then in build/install/<project_name>/bin you will find the start files. On windows execute the bat file.
That works, but i get errors with file locations, because doing this messes with them. Is it possible to fix that
apart from that tho i did manage to move away from the file dependancys and use the link ones
I uploaded your attachments as Gist. This makes them more accessible, for example to mobile users.
using installDist .bat file (as compiled version) but it messes up file paths
What code throws this error?
one sec
public static void takePartialScreenshot(String threadName, int part) throws IOException {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gd = ge.getDefaultScreenDevice();
GraphicsConfiguration gc = gd.getDefaultConfiguration();
// Full screen bounds
Rectangle screenRect = gc.getBounds();
// Taskbar/dock insets
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
// Adjust for taskbar/dock
int usableX = screenRect.x + screenInsets.left;
int usableY = screenRect.y + screenInsets.top;
int usableWidth = screenRect.width - screenInsets.left - screenInsets.right;
int usableHeight = screenRect.height - screenInsets.top - screenInsets.bottom;
// Calculate halves based on *usable* screen size
int halfWidth = usableWidth / 2;
int halfHeight = usableHeight / 2;
// Define the 4 parts:
// 1 | 2
// -----
// 3 | 4
Rectangle partRect;
switch (part) {
case 1 -> partRect = new Rectangle(usableX, usableY, halfWidth, halfHeight); // top-left
case 2 -> partRect = new Rectangle(usableX + halfWidth, usableY, halfWidth, halfHeight); // top-right
case 3 -> partRect = new Rectangle(usableX, usableY + halfHeight, halfWidth, halfHeight); // bottom-left
case 4 ->
partRect = new Rectangle(usableX + halfWidth, usableY + halfHeight, halfWidth, halfHeight); // bottom-right
default -> throw new IllegalArgumentException("Part must be 1, 2, 3, or 4");
}
// Capture only that region
BufferedImage screenImage = bot.createScreenCapture(partRect);
// Save it
File outputFile = new File("src/main/resources/images/screenshot/screenshotPart" + part + "Thread" + threadName + ".png");
ImageIO.write(screenImage, "png", outputFile);
}```
I uploaded your attachments as Gist. This makes them more accessible, for example to mobile users.
Those 2 functions
its something to do with how file paths are used when complied to a .bat
You shouldn't be trying to write into src paths... those wouldn't exist if you only distribute the compiled application.
ok, where is the correct place for image, ini files etc?
that works correctly
Either as a location relative to the user's profile, or an application installation or work folder.
resources and source files are used to build the distribution (usually a jar) that is passed to the JVM to run the application - it's not a file-system, and you'll need some form of storage to store content managed at runtime.
what im confused about, is how im going to put files somewhere that can be used by both uncomplied and the compiled .bat version
like i would have to add the files myself to the .bats location i guess and change some stuff but i just don't know how to do both
a .bat file isn't ever 'compiled'... it's a script.
yeah, i know but its what i mean
it still simplifies the files down a lot, which makes it better for releases
and doesn't need a IDE or jarfix
Batch files can reference paths relative to themselves. If you're distributing your jar file a a batch file to launch it (requiring a JDK too) then you can bundle the images and other files alongside it.
I get that, but what i don't get is how im meant to have a working path that doesn't need replacing before i turn into a .bat script
i really don't know how to explain what im meaning tho which is quite a issue
bc if its based off where the .bat is, wouldn't that be different to basing it off where the .jar or the java files are
I don't understand why you need to 'replace' a path. If the path is in a known relative position to the .bat file, then you can work out the path.
bc your in a different file structure
k
The Java files aren't something you distribute, the jar file is (containing the class files compiled from Java and resource files)
One option, when invoking java from the batch file, would be to pass the 'home path' as Java system property to the Java program. This way, the program's 'working folder' doesn't have to change.
And the program can load all of its files relative to that 'home path'.
home path for me would be inder pytorchmacro [JavaMacroTool] right?
so if the files are in the "files" folder (i couldn't think of a better name) as shown, if i copy+paste that same files folder beside the .bat would it be able to read those with the same path, which is based on the "programs working folder"
A batch file can read its own path
Something like (I haven't used batch files for a while)
@echo off
SET BASE_PATH="%~dp0"
echo "My path is %BASE_PATH%"
like this? set APP_HOME=%DIRNAME%..
If the application home is the same folder as where the batch file is, then the %~dp0 is that path.
%0 is the batchfile full path and drive, including the batchfile name. ~d extracts the drive letter and ~p extracts the path... %~dp0 is therefore the drive and path of the batch file.
So if your application folder was
...someplace...\
launch.bat
jdk\
...
lib\
foo.jar
bar.jar
images\
...
Then you could do something like
@echo off
set BASE_PATH="%~dp0"
set LOCAL_JDK="%BASE_PATH%"\jdk
"%LOCAL_JDK%"\bin\java.exe -cp "%BASE_PATH%"\lib\*.jar -DAPP_HOME="%BASE_PATH%" some.application.Main
And your application could look up String appPath = System.getProperty("APP_HOME") to look for Path.of(appPath, "images")
No idea if all that escaping is correct.
And in your project you just want to compile your code to produce the application jar file.
This is a utility to get a writable directory in the users directory.
I uploaded your attachments as Gist. This makes them more accessible, for example to mobile users.
got it working
is it possible to make a .sh (or whatever the linux .bat equavilient is) with installDist or something simular
thanks