Skip to content

Instantly share code, notes, and snippets.

@lramosduarte
Created February 19, 2021 11:34
Show Gist options
  • Save lramosduarte/87016b4aa5c42e2714f83760502424ca to your computer and use it in GitHub Desktop.
Save lramosduarte/87016b4aa5c42e2714f83760502424ca to your computer and use it in GitHub Desktop.
Using Jshell like a pro(or newbie if wanna)
# Extract jar files
```bash
$: jar xf JAR_FILE.jar
```
## Check files
File structure containing the application's dependencies.
# Running
```bash
$: CLASSPATH="PATH1:PATH2" jshell
```
Example SpringAPP:
```bash
$: CLASSPATH="target/BOOT-INF/classes/:target/BOOT-INF/lib/*" jshell
```
**The classpath is required**
## Start app contenxt
After start `jshell` with jar context, then start `main method` and you will have access to all beans
```bash
jshell> import path.to.main.class
jshell> var app = MainClass.main(new String() {})
jshell> var repository = app.getBean(BeanRepository.class)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment