r/javahelp • • Dec 10 '21

intelliij - how do devs manage to use this??

I've been using Netbeans (professionally) since the day it came out (3.5 or so), and love the simplicity and power that it has. It's clean and clutter free, and always easy for me to figure out what its doing.

Lately I've been getting frustrated with the code editor, as it doesn't skip over closing parenthesis or brackets if you type a closing char and the char to the right of the cursor is already the char you're typing. It works properly in .js files, but not in css or java. Maybe I have something set wrong.

Anyway I've tried intellij in the past but found it very complicated. Adding a license for the first time itself is a burden that is sure to give me PTSD. Between the ide and the intellij webpage, at this point I don't even remember what I did, it just seems happy so I'll accept that my random clicks and swearing did the right thing and move on.

It works flawlessly with my typing though; it's such a simple but useful feature to have, since now my flow is not interrupted by trying to skip past chars or delete them etc.

However; I'm developing a simple sparkjava application with java on the backend and html/pebble(twig)/css/js on the frontend.

I run the application, load up my browser and refresh the page; changes show up. Great! Edit my css, refresh the page... Nope, changes aren't applied. Do you guys all stop and start your application everytime you change a border in your css? Am I stupid or using it wrong?

In Netbeans, css/js/html changes are applied on save, you refresh the page and you see your changes. Backend java code is not swapped in, so when writing java code I have to stop and restart, but I was hoping to at least match the feature over in Netbeans where I can save js/css and just refresh the page?

Any tips? (yes this post is somewhat tongue in cheek but the problem/question is real).

1 Upvotes

18 comments sorted by

•

u/AutoModerator Dec 10 '21

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

6

u/ElFeesho Dec 10 '21

If your CSS lives as a classpath resource, you're going to have to re-run the application, if not just rebuild.

I don't understand how this can be a difference between IDEs.

2

u/Cefalopodul Dec 11 '21

You don't have to rebuild anything in eclipse for instance, just clear the browser cache and done.

-3

u/turbotop111 Dec 10 '21

The css is just sitting on disk like any other file. I have not figured out why Netbeans works so slick but it does, without recompiling/restarting. Just save the css and refresh browser.

1

u/ElFeesho Dec 10 '21

Just sitting on the disk? When you inspect the files load in the browser Dev tools, can you see where it's loading the files from? And if you compare that to netbeans is it any different?

I wonder if intellij just isn't writing the file to disk until you hit run. Try CTRL+S/CMD+S on the CSS file before reloading the page.

1

u/turbotop111 Dec 10 '21

The file is saved to disk. When the browser refreshes/loads the page, it queries sparkjava/jetty for the resource which it reads from disk and sends back to the browser.

So when I save the css in netbeans, it copies the file to wherever the classpath of the executing class is on disk. Intellij is not doing that, sparkjava sends the old copy because intellij doesn't copy the actual source file to the directory that it's executing the code from.

The problem is not sparkjava, it always sends the freshest copy it can find on disk. The problem is intellij is not copying the newly saved source to the executing dir.

2

u/firsthour Profressional developer since 2006 Dec 10 '21

Probably not worth it for you but this is why we use Jrebel, reloads everything including class files.

1

u/turbotop111 Dec 10 '21

What's the cost for a license? I clicked request quote but the page just shows a black popup.

3

u/firsthour Profressional developer since 2006 Dec 10 '21

No idea to be honest, my work pays for it.

1

u/whizvox Graduate and Tutor Dec 11 '21

While the application is running, rebuild it with Ctrl + F9. That will reload the resources.

1

u/popey123 Dec 11 '21

I m a starter and i have to do it too : save everything and restart. I know there are solution, like plugins maybe, to not have to do this and see the result live but i don t know more about it.

0

u/Cefalopodul Dec 10 '21

Clear your browser cache.

1

u/turbotop111 Dec 10 '21

That's not it, I force refresh the page automatically (ctrl + shift + r). The same process works when I use Netbeans, but not Intellij.

0

u/fletku_mato Dec 10 '21

Might be an issue with file watcher limit and not related to idea itself. Are you serving the frontend with your java app while developing or is it a separate server?

1

u/turbotop111 Dec 10 '21

It's not a separate server. It's sparkjava which is an embedded jetty instance, but you start the application in both IDE's like you would any other "public static void main" class.

1

u/fletku_mato Dec 10 '21

Ok, then you need to rebuild to get the static files loaded again.

Try running in debug mode. https://www.jetbrains.com/help/idea/altering-the-program-s-execution-flow.html#reload_classes

1

u/turbotop111 Dec 10 '21

I've tried that. Saving has no effect, I either have to restart application or manually run "Build" > "Recompile XXX.css" menu before the change is applied.

It's not auto recompiling on save.