'Problems' in VSC not finding basic typing errors - java

I'm writing code in Java using Visual Studio Code for a project I'm working on. I've been quite pleased with the environment until now, when the 'Problems' window seemed to stop detecting I've made basic typing errors. Right now it detects some errors, but it doesn't detect, for example, when I'm using variables that haven't been declared.
E.g. if I would just have a basic main function and run only the line "int a = 0 + foo", VSC would not detect that 'foo' hasn't been declared. Does someone have an idea about what could be causing this? I might add that I have not done anything out of the ordinary that could causes this (the best I know), and I've done 3-4 projects before without running into this problem.
I've only tried Googling the problem. Since I'm quite inexperienced in this field I don't really have any thoughts on what could be the cause of this.

Related

Why doesn't Android Studio see updates right away?

I am using Android Studio 4.1.1. windows 7. I write in Java. I noticed this feature of the program. Changing something in code, layout or resources. I run the program and see that my changes have not appeared! First comes the thought that I was wrong somewhere. I start looking for an error. I don’t find it. I run the program again and it already works as it should. Now I'm used to it. The larger the program, the more often this happens. To be sure of the result, you have to run the program twice each time, because I'm not sure if this time all the changes took effect. It is very uncomfortable. Tell me why this is happening and how to solve this problem.

How can I make it so Eclipse automatically updates my code in a window as I edit it?

How can I make it so Eclipse automatically updates my code in a window as I edit it? I've seen the feature before in youtube videos but I cannot find it. For example : I change a JApplet rectangle width from 20 to 10, I want to see it update immediately.
I've seen Notch do this on development videos (Minecraft), it is awesome but I don't know exactly how he does it.
-- EDIT --
This has been bugging me so I went and googled "how does notch code" and found this on a blog page https://gun.io/blog/what-i-learned-from-watching-notch-code/. It doesn't say exactly how it was done but gives a good hint (HotSwap) and makes it seem like he set it up himself without external software. Here's the most relevant section:
Incredibly Fast Testing
He began by building the engine, and to do this he used the ‘HotSwap’ functionality of the Java JVM 1.4.2, which continuously updates the running code when it detects that a class has changed.
When building the engine, Notch wrote a function which would continuously pan the camera around and clip through the walls and keep the view on top, so he could make changes to the code and see the effects they made in real time. I’m used to testing by writing a function, building it, installing it on the device I’m testing on, and then seeing the result, which can take up to a minute at a time, so it’s easy to see how HotSwapping could save a lot of development time.
--- ORIGINAL POST CONTINUED ---
I get a similar effect by using groovysh though, works smoothly and can use all your java classes as is.
What I'll usually do is write all my code in java, then go and fire up "Groovysh" where it will give you a little window to enter commands (You may have to ensure the classpath works correctly outside of eclipse). I can then "new" any of my classes and call methods on them one line at a time. When you do myFrame.setSize([100,100]) you will see it change immediately.
A good test is to just run groovysh and type something like:
import javax.swing.*
f=new JFrame()
f.setVisible(true)
f.setSize(100,100)
or the groovier version:
f=new JFrame(visible:true, size:[100,100])
and you will see your frame resize on the screen. You can even drag it bigger and then do something like:
println f.getWidth()
to show your new width. It's fun to interact this way but it's more complicated if you want to actually change your class definition and see it pick up the change, I have no idea how Notch did that. I looked into it a little--it's possible he was using something like JRebel
It requires something special since you would have to dynamically reload the classfile into your running system on every save--something that should have serious classloader issues.
By the way there is also a way to get your Java program to throw out a little GroovyConsole which will allow you to inspect and modify all the variables in your running code (but again you can't replace definitions of existing classes).
Also see answer here:
Change a method at runtime via a hot swap mechanism

Real-time compilation in IntelliJ IDEA

I have recently switched from IntelliJ IDEA Community Edition version 12, to version 13 (updated to 13.0.1) and apparently the real-time ("on-the-fly") compilation of code does not work, at least not as found in other major IDEs (e.g., Eclipse).
A similar issue has been brought up in an earlier StackOverflow question and the answer was to check the corresponding option in File -> Settings -> Compiler, which I have of course done, but nothing changed.
The way it currently is, I can type whatever text in the Java code and there is no error highlighting, not even when the file is saved, let alone in real time.
Is there another setting or configuration that needs to be applied?
IntelliJ does something a lot better than compiling your files on the fly. It dynamically parses what you're typing, offering many more warnings than the java compiler produces. In comparison, compiling on the fly is a bad idea. Having said that, it sounds like you're having other problems, because you should have errors and other problems highlighted. At the top right of each editor window is a small coloured square. On good code it's green. It's yellow when there are warnings, and red when there are errors. If it's grey then Idea is analyzing your files. If you hover your mouse over the square it'll give you an idea about what Idea is doing, and how it's progressing. Try that before you try anything else. Idea never gets stuck, but it can run out of memory, if the analysis isn't progressing, then perhaps you've run out of memory, or have other issues, check this in the event log, which is at the bottom right of the window.
I've just been pulling my hair out over this working on my Mac in a coffeeshop running on battery power. Try File | Power Save Mode and make sure it's un-checked.

Strategies for debugging a runtime Java crash that runs correctly in NetBeans

Sorry in advance. This is a really vague question because I have no idea whatsoever what is going on. I have a Java Swing GUI desktop app that I wrote in NetBeans. While inside of NetBeans, the app works fine and passes all of the tests that I have thrown at it. I've been developing this app over the past several months, deploying it at various phases of its development.
Yesterday, I finished adding and testing some new functionality. I built the application and put it on another computer. I then went to run the program (outside of NetBeans) straight from the jar file. While in the new areas (JDialog boxes), the program crashes. Since I am not in an IDE, I have no feedback to see what is wrong.
The only thing that I can think of (and this is lame) is that I added some switch statements that switch on strings, which I know to new to 1.7. I was previously developing in 1.6. Otherwise, I can think of no reason that the program should work flawlessly inside the IDE, but crash outside of it.
Can anyone offer any suggestions for how I should approach this? I'm at a complete loss.
Thanks very much.
The next debugging step for you is reducing the size of your program until it doesn't crash, then seeing what change you made worked. That should either make the answer obvious or give you a good question to post on SO.
Your idea that it might have to do with switch statements tells you to try:
removing them
removing and compiling on JDK 6 and see if it works
Those are reasonable ways to reduce your program size to see if you can make it run.
I would start from collecting a crash dump data.
If you run the UI on windows you could use DrWatson
If you run the UI in Linux , By default the heap dump is created in a file called java_pidpid.hprof in the working directory of the VM. unless you specify the path yourself by adding this -XX:HeapDumpPath= option to your UI java options.

Eclipse quick fix not working properly

I am very new to Eclipse, java programming and well all "programming" in general and I have recently been learning how to use Eclipse. I've been using it for about a week now and it has been going decent so far. Apart from some errors,(mostly on my part) that has been fixable by restarting the program itself.
However when I started using it today I could no longer see the suggestions made from the Quick Fix command, for example if I type findVi and then press CTRL+1, it shows "No suggestions available" instead of "findViewById()" or something similar.
I know it's the correct binding, I even reset the keys to default to be sure. It still finds the ID if i type it manually but I would like to able to finish words faster that way.
If you guys got any suggestions that can help me out, please let me know.
Thanks.
- First of all if you are new with Java, and want to practice Java, you should NEVER USE ANY IDE, that way you learn the proper syntax, and it helps your error finding skills.
- But as you wrote "findViewById()" it seems that you are doing Android, Now this happens sometimes that Eclipse behaves weirdly with Android. Thats the reason when you make any changes into your Eclipse GUI while working with Android, its always better to see if those changes have taken effect.
- This problem usually goes off after closing and re-opening the Eclipse once or twice.
- Ok try this....
Type findVie then press Ctrl + Space-Bar See if the suggestion pops up...
You can access the Content Assist preferences from Window > Preferences > Java > Editor > Content Assist... perhaps something got messed up.

Categories

Resources