In my spring Boot web app I have added the Gradle Wrapper to source control so that a user does not need gradle pre-installed to run my application.
My project file Structure is shown below - note the gradle folder with gradle-wrapper.jar , gradle-wrapper.properties and gradlew batch file are present.
However when try to run gradlew clean build in this folder I get:
gradlew:command not found
How can I solve this?
You're missing the . dot in your command. And from your screenshot, you're own a Windows machine so you should use the .bat script.
./gradlew.bat help
Related
I am creating a spring boot application using gradle. I need to create
a jar which include all needed libraries for deploying on (aws) ec2
instance.
I am trying to create a jar by...
1)click on project structure
2)then click on Artifact
3)click on + -> jar -> from modules with dependencies -> select project -> select main class
4)click on ok with default settings
5)click on build tab
6)I got a jar file but it doesn't contain classes.
Use Terminal/Command Prompt to generate jar using Gradle
To generate jar without running test cases
./gradlew build -x test
If you want to run the test cases before creating jar, then
./gradlew build
First make sure you have downloaded gradle and set up in your system variable.
to check this simply run gradle -v in your cmd.
Under System Variables select Path, then click Edit. Add an entry for
C:\Gradle\gradle-6.5.1\bin. Click OK to save.
Now you simply goes to project directory and run
./gradlew build -x test
Now you get your executable jar file
I have completed my JavaFX application within gradle build system, and it is working fine in all way. Now I want to export as a .EXE file for standalone software distribution, I tried much more tricks but no gain. If some one can help me out to wrap my project in a software setup, It would be grateful.
Follow these steps to export your JavaFX project into executable Jar
Goto> Project Structure
Goto>>Artifacts
Click "+">> To add new artifact
It will shows a dropdownlist
Select>>Jar>>From module with dependencies
You will see a nested window as shown
Select Main class of your project
Check In the Option " Copy to output directory.." >>Ok
Goto>> Menu-bar>>Build>>Build Artifacts
Select>> your Project.jar>> Build
This will create executable jar file in your project source folder
Locate your jar file in path project\out\artifacts..
Now you can run this jar file simple cmd commad or with batch file
Cmd Command>> Java -jar project.jar
Using batch file>> make .bat file name it "RUN" and write these commands inside
Specify the Java Runtime path and "Javafx Sdk path" along with VM
options & Project Jar
Run your standalone application .. Enjoy ;)
Creating an installer for the desktop platforms (Windows, macOS, Linux) has become easy these days. The tool of choice is jpackage which started to be shipped with JDK 14. It can either be used on the command line on the finished project or you can use a Gradle plugin (https://github.com/beryx/badass-jlink-plugin). If your project is not modularized you could follow this tutorial https://github.com/dlemmermann/JPackageScriptFX which also uses jpackage but together with Maven and some other tools from the JDK. The Maven part could easily be rewritten to Gradle, if needed.
I have developed a Spring Boot Application using Restfull API. The application working perfectly in STS. But now i am trying to run a jar file in linux, any idea.
You can generate runnable jar file using 2 ways.
a. Exporting as JAR file from STS.
Right click on project in STS --> click on Export --> search for jar
--> click on JAR file --> select project --> select resource to export --> Select checkbox : Export Java source files and resources --> select the export destination --> give a name for JAR file (for
example abcd.jar) click finish to generate JAR file.
b. Using Maven.
First, make sure that you have the repackage goal included in your
build setup, then use the Maven package target. The simplest way
to do this is to run mvn package from the command line (you may need
to install the Maven CLI package for your OS); you can also
right-click the POM in Eclipse and "Run As" to execute specific Maven
operations from within Eclipse.
To run JAR file open command/terminal prompt and reach to destination where JAR file was created. then execute command java -jar abcd.jar
Can you follow the steps
check the version which you have installed in Linux
java -version
Install the JDK corresponding to your application version which you have created application
sudo apt-get install openjdk-version-what you want JDK verson -jre
// example - sudo apt-get install openjdk-7-jre
Run the application simply typing
java -jar Minecraft.jar
Not being able to execute the default micronaut application using basic cli commands. This problem has occured on both the Maven and Gradle default projects. I don't understand why I'm having issues running the app.
The repective default project base directories contain the mvnw and gradlew files so I don't think it's a problem with maven/gradle being out of date on my computer or anything along those lines.
I've checked the class path being passed into the arguments in both the gradlew and mvnw bat and cmd files. Their respective wrapper.jar paths are being passed in as classpath arguments.
Here's some images.
Maven error message, similar error occurs when trying to run with gradle:
Base directory of maven project:
Gradle error message:
Base directory of gradle project:
Parent directory image:
UPDATE: I just tried downloading someone else's project directory from a guide on micronauts website I unzipped it and used the ./gradlew run command, the server seems to be up and running. The zip comes with initial and completed subdirectories each with their own micronaut application inside, they run too using the same gradle command.
This leads me to believe that there was something wrong with my micronaut installation. Maybe it's shipping a faulty default application (that's not configured properly)?
It looks like you don't have the wrapper support files in your project.
~ $ mn create-app somedemoapp
| Generating Java project...
| Application created at /Users/jeffbrown/somedemoapp
~ $ cd somedemoapp/
somedemoapp $ rm -rf gradle
somedemoapp $ ./gradlew run
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
(notice that I deleted the gradle/ folder before attempting to run the project)
Some people don't check in the gradle/ directory to source code control because they don't understand its purpose.
I created a new micronaut application in my C drive with a different directory, it worked. I think it has something to do with the original path variable having too many spaces and - in it. Making the classpath (in the gradlew.bat) unreachable essentially.
I want to converte my Maven project to Gradle.
In official Gradle docs is written "All you have to do is run the command
'$ gradle init'
from the root project directory and let Gradle do its thing.",but I can't understand one thing - where exactly in the root project directory i should write this init command.
I tried to cd into the project directory in Windows Terminal and after this run init gradle but it doesn't work.
This is my project directory
Can someone help me?