Last active
April 16, 2022 17:19
-
-
Save vinkrish/cb9db8bce70b94a3ae01f3fe84087276 to your computer and use it in GitHub Desktop.
Commands for building java application
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 characters
vi ~/.bash_profile | |
vi /Users/vinkrish/.bash_profile | |
export JAVA_HOME=$(/usr/libexec/java_home) | |
source ~/.bash_profile | |
echo $JAVA_HOME | |
/usr/local/Cellar/openjdk/17.0.2/libexec/openjdk.jdk/Contents/Home | |
earlier JAVA_HOME: | |
Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home | |
javac -version | |
javac FileName.java | |
java FileName | |
jar cf jarName.jar fileName.class | |
// using spring_sample project in workspace | |
java -cp target/spring_sample-0.0.1-SNAPSHOT.jar info.vinkrish.Application | |
java -jar target/spring_sample-0.0.1-SNAPSHOT.jar | |
java -jar lombok-1.18.22.jar | |
// using lombok | |
javac -cp lombok.jar Student.java | |
javap Student.class | |
// if using -vm to start eclipse | |
-vmargs -javaagent:lombok.jar | |
java -jar --add-opens java.base/java.lang=ALL-UNNAMED app.jar | |
// If you are running in IDEA, you need to configure the corresponding VM parameters | |
--add-opens java.base/java.lang=ALL-UNNAMED | |
// see the bytecode of the class | |
javap -c Point.class | |
To run java file inside jar file: | |
java -classpath jarName.jar fileName | |
javac -classpath ./lib/* fileName.java | |
java -classpath ./lib/*:./ fileName | |
The classpath is simply the location, or set of locations where class files can be found, that your program might need to use. The classpath includes folders, JARs, and (in certain more complex setups) other sources of classfiles. | |
When Java needs to load a class, it looks on the classpath for it. The default classpath is the set of Jars that contain Java's built-in classes, combined with the current directory of your shell prompt. | |
java -classpath /Users/vinkrish/Workspace/java/MyClasses;/Users/vinkrish/Workspace/java/OtherClasses | |
jar files are like zip files: | |
unzip jarName.jar | |
mvn --version | |
mvn clean | |
mvn package | |
mvn clean package | |
mvn clean verify -DskipTests | |
mvn clean verify -DskipITs | |
mvn dependency:tree | |
./mvnw --version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment