java/javac only sometimes recognised in command prompt - java

I just recently started trying to work with Java, I have set the path variable and on first try it worked fine, but now whenever I boot I have to go check the variable (not set it again, just open the control panel, Advanced System Options etc... and then close it) to make it work, otherwise it just says it's not recognised as internal command, as if the path variable was actually not set. If I keep working it stays fine but if I don't do anything for about an hour the problem comes up again (without reboot).
This seems like a very weird problem and I have no idea what could cause it.

Related

Use external terminal window instead of the integrated one

I don't want my input/output to appear in the integrated Terminal, I want IntelliJ to open and use a new cmd.exe window each time I execute the program. Is that possible?
Edit: For clarification, since apparently I was using wrong terminology (sorry about that): By 'integrated terminal' I meant the 'Run' window (where all the System.out.print stuff goes).
So basically I want my program's output to not be shown inside this Run window, but rather inside a new terminal window (cmd.exe preferably), just like if you would start your programs from the terminal itself.
Is that still possible? Because I think it was at one point in the past. And if not, why?

java console does not update with the changes in my source code

I am trying to set up a java project and so far everything is working as one can see in this screenshot:
However when i adjust my code, the console does not update as wel as we can see here:
I tried to check path -> build automatically and clean the project but this does not work. I also terminated the console and restarted it but this did not help as well. Anyone can help me with this problem?
Kees
The answer was actually quite easy. I assumed Eclipse automatically saves your changes when re-running the console but this was not true. Thus when i just save the file it runs perfectly fine. Can't believe I spend a hour not figuring this out.
Kees

How on earth does he debug a running application like this, and more importantly, how can I?

"Debugception!"
You may notice that within the first 15 seconds of this YouTube video (from 1:01:01 to 1:01:16), Markus Persson (aka "Notch", creator of Minecraft) has somehow managed to save/update an application and attach a debugger to it while it was already under the process of being debugged, supposedly all with a simple keyboard shortcut. The previously coded application somehow magically became the newly edited one, and seemingly without relaunching it or spawning a new process... It's possible that this is just some form of locally remote debugging, but something about it just doesn't seem quite right.
I've spent several days Googling and asking around on how he was able to do this, yet to no avail. I've found no such option under Eclipse preferences, and whenever I try to save & debug an already running application, it simply launches a separate instance of the newly updated application, side-by-side with the older, outdated one.
Am I missing something? How was this possible?
How was he able to utilize such an astounding, powerful debugging feature?
Thanks in advance!
Update
Okay, so this appears to be a standard feature specific to Eclipse.
Coming from a background in NetBeans and Visual Studio, I'm astounded that this doesn't seem to exist elsewhere (or at least in NetBeans!)...
This is a built-in feature of Eclipse. If you edit a method while the program is running in debug mode, it will compile the new method, and replace the old method with the new version. If some thread was already running that method, it will jump back to the beginning (AFAIK; this might only happen when the program is paused).
You don't need to re-launch the program or set any special preferences. Just edit and save, and the magic will happen.
Eclipse can't always figure out how to merge your changes into the running program - usually if you changed anything outside a method body (including the method's parameters or return type). In this case, you will get a warning dialog, with the option to stop the program, restart the program or ignore the changes.

Java eclipse - value changes itself at the start of the program

Usually I know what the problem is or how to describe it. But this is just beyond my understanding.
I have a set of public static variables in my main class, the first thing that happens in the main(String[] a) method of the project is displaying two of those. But for some reason when I changed it in the declaration, the program still runs of the old one. I have attempted removing the static and calling them from within the method with the same result. As far as I can test all variables in this section of the program suffer from the same problem.
Here is the screenshot of the code and variable (I made a break point on the main method just to be sure nothing else runs):
In case this matters, I have actually changed computers since the last version of the app, I have a new installation of everything but I rebuild all directories as they were and besides this variable change (or lack there of) everything runs with no issues.
Ok it took a bit of thinking outside of the box but I've fixed it (not all steps may be required, but when tried on their own they didn't work):
Close all tabs (files) in Eclipse
Close Eclipse
Open and save (without editing) the .java file in other program (like Notepad++)
Open Eclipse
Right-Click inside Package Explorer and 'Refresh' (or use F5)
Open the file and build the project
It's a very strange bug and I hope if someone else finds it the 'fix' will work for them.

Debugging with JUNIT4: eclipse "stops" at breakpoints but actually keeps running

I'm using Eclipse Juno to debug a java class while testing with junit, but the debugger has been acting flakey. I will reach the breakpoint I want and all seems well with the variable values, but in my console, all of the print statements I set up later in the code are popping out as if I were stepping through it!
(note: they aren't printing as fast as they normally would if I had simply run it, and the output itself is a bit garbled compared to normal output).
Somehow, the code is executing through without me pressing a button. If I try to step through, my view of the code and variables is correct, but debugging stops once Eclipse thinks the program has finished.
Something I should probably mention is that I recently put Fedora on my laptop, so I haven't been running eclipse on it for very long and this is my first time trying junit. Is is possible that I need to download something for my debugger?

Categories

Resources