Giter Club home page Giter Club logo

Comments (13)

PascalLeMerrer avatar PascalLeMerrer commented on May 18, 2024 3

According to me, this would be an important feature to add to Javalin for it to be a nice backend for SPA development

from javalin.

tipsy avatar tipsy commented on May 18, 2024 3

@PascalLeMerrer For static files you don't need to restart the server, you can either just build (will copy files to jar), or use enableStaticFiles("/path", Location.EXTERNAL). If you use an external location, all you have to do is save and refresh.

from javalin.

geekytime avatar geekytime commented on May 18, 2024 1

No, I don't use IntelliJ or Eclipse. I should probably just give in and use an IDE the next time I work on a JVM project.

from javalin.

tipsy avatar tipsy commented on May 18, 2024

Hi @geekytime. Unfortunately I don't have any experience with this myself, neither with maven nor with gradle, but I would love to get it working. I was under the impression that you would need something like JRebel or DCEVM though, but maybe this isn't the case? It would be great if you could look into it.

from javalin.

tipsy avatar tipsy commented on May 18, 2024

https://github.com/HotswapProjects/HotswapAgent <- might be worth looking into.

from javalin.

jwhitmarsh avatar jwhitmarsh commented on May 18, 2024

@geekytime did you have any success with this?

from javalin.

geekytime avatar geekytime commented on May 18, 2024

No. I tried for a few days and then gave up.

Kotlin and Javalin make it pleasant to code a web server on the JVM. Unfortunately, between slow compile/startup times, lack of hot-reloading, and having to deal with maven or gradle; running a web server on the JVM will likely always be an exercise in frustration. 😖

from javalin.

tipsy avatar tipsy commented on May 18, 2024

@geekytime are you using IntelliJ or eclipse? Rebuild+restart should take less than a second. There is also debug-mode in IntelliJ which should give some (limited) hotswapping.

from javalin.

tipsy avatar tipsy commented on May 18, 2024

@ShikaSD @iProdigy do either of you have any experience with this? Or any interest in finding out how we can achieve automatic class reloading?

from javalin.

gkopff avatar gkopff commented on May 18, 2024

I notice in this thread you already found HotswapAgent - but I still thought I'd mention this project I came across which seems to use HotswapAgent to do hot page reloading. Perhaps it can give you a clue ...

https://github.com/kwebio/core/blob/master/src/main/kotlin/io/kweb/dev/hotswap/KwebHotswapPlugin.kt

from javalin.

tipsy avatar tipsy commented on May 18, 2024

I found these instructions for "Kweb":

Step 1 : Install Dynamic Code Evolution VM (DCEVM) Java patch
Go to https://github.com/dcevm/dcevm/releases and download the latest DCEVM light installer (DCEVM-light-8u112-installer.jar at the time of writing).

Run the installer by double-clicking on it.

Note for Mac users: You may get an error like “DCEVM-light-8u112-installer.jar” can’t be opened because it is to an unidentified developer, if so you should control-click the file and select “Open” to the drop-down menu, then click “Open”.

You must now select your Java Development Kit directory. If it isn’t already listed click Add installation directory, for example on a Mac it may be /Library/Java/JavaVirtualMachines/jdk1.7.0_121.jdk/Contents/Home.

Click Install DCEVM as altjvm.

When the installation is complete you can quit the DCEVM installer.

Step 2 : Download HotSwapAgent
Go here and download the latest hotswap-agent .jar, (hotswap-agent-1.1.0-SNAPSHOT.jar at the time of writing).

Save it somewhere appropriate, perhaps in a directory called javalibs in your home directory (it doesn’t really matter where you put it but you’ll need the full path and filename later).

Step 3 : Modify your project’s run configuration
In intelliJ select Edit Configurations... under the Run menu, and paste the following into the VM Options field:

-XXaltjvm="dcevm" -javaagent:PATH_TO/hotswap-agent.jar=disablePlugin=AnonymousClassPatch

Be sure to edit PATH_TO/hotswap-agent.jar to be the full path and name of the hotswap-agent .jar file you downloaded in Step 2.

Note that =disablePlugin=AnonymousClassPatch was necessary at the time of writing to prevent a non-fatal error, but this bug in HotSwapAgent has been reported and may be fixed by now.

Step 4 : Configure Kweb to refresh webpages automatically
Set the refreshPageOnHotswap Kweb constructor parameter to true:

    Kweb(port = 1234, refreshPageOnHotswap = true) {

Most of it looks pretty general. Might have to look at what Kweb does for refreshPageOnHotswap = true.

Edit: @gkopff hah, thanks!

from javalin.

gkopff avatar gkopff commented on May 18, 2024

The Kweb author posted on reddit: https://www.reddit.com/r/Kotlin/comments/8d6afi/kweb_rapidly_build_rich_web_apps_in_pure/ and I PM'd them a link to this issue to see if they were interested in helping out.

from javalin.

sanity avatar sanity commented on May 18, 2024

Kweb author here, it's been a while since I did the hotswap stuff, it was a bit fiddly but I managed to get it working eventually. @gkopff has already provided the relevant pointers, happy to answer any questions.

from javalin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.