#project runs in the IDE but not when a jar
92 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @narrow pasture! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
no error no nothing
just does nothing
when i open teh jar in a java decompiler it shows all the correct files
this is also the case for other projects not just this one
even tried using cmd to compile it and still doesn't work
it used to work though
What is the cylorun file?
So that's a folder. Where is your jar file?
Are you able run your program by typing "java Main" in your Command Prompt?
it's just the package name
how would i do this
i used to be able to compile shit into jar files but now they don't work
i tried cd path to project root
and java Main
or path to the jar
Open Command Prompt
Make sure it is direct to the same folder as your class files
Type java Main
Error: Could not find or load main class main Caused by: java.lang.ClassNotFoundException: main
what are the contents of your MANIFEST.MF file inside your META-INF folder ?
Manifest-Version: 1.0 Main-Class: me.cylorun.Main
how did you build the jar ?
project structure> artifacts> jar from modules with dependencies> all modules, me.cylorun.Main
then ok
build>build artifacts>build
IntelliJ btw
what's the name of the jar
shfinder.jar
open cmd navigate to the correct folder then type:
java -jar shfinder.jar
tell me what the output is
correct folder, the folder in which the jar is located. Alternatively provide the full path to the jar
no main manifest attribute, in shFinder.jar
you aren't using a build system like maven or gradle, are you ?
then you don't build the jar through intelliJ but through gradle. Gradle should provide the task build->jar
build->jar : The term 'build->jar' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
- build->jar
-
+ CategoryInfo : ObjectNotFound: (build->jar:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
uuh 😅
maybe im running it in the wrong place
did you try running build->jar in your console xD
in the top right corner you have a gradle tab
I meant that you execute the task in there
alternatively you can run ProjectName [jar] in your console or gradle build jar
in your build directory
it's not there
hmm did the task complete successfully ?
seems like it
this is what it says
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :jar UP-TO-DATE
BUILD SUCCESSFUL in 102ms
3 actionable tasks: 3 up-to-date
21:28:04: Execution finished 'jar'.
could you share your build.gradle file
id 'java'
}
group 'me.cylorun'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
url "https://jitpack.io"
maven { url 'https://maven.izzel.io/releases' }
}
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation 'com.github.KaptainWutax:SEED:master-SNAPSHOT'
implementation 'com.github.KaptainWutax:MathUtils:5531c4a87b0f1bb85d1dab2bdd18ce375400626a'
implementation 'io.izzel:nbt:1.1.0'
}
test {
useJUnitPlatform()
}```
yeah I figured. You need to add this block and configure it:
jar {
manifest {
attributes "Main-Class" : "path.to.Main"
}
}
yeah its in build/libs
where did you add the jar block ?
at the bottom
and you did configure it ?
yeah
the jar is compiled and appearing ?
jar { manifest { attributes "Main-Class" : "me.cylorun.Main" }
yes
and what's the output when running in the console
you are trying to bundle the libraries inside the jar
yes
... you should have lead with that
oh shit
alright inside plugins add
id 'com.github.johnrengelman.shadow' version "7.1.2"
then run the shadowJar task that should have appeared
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
sorry for being kinda dumb regarding this stuff
