That's a pleasure
Antonio Moretti wrote:Thanks . . .
It tells the compiler and runtime where to seek other code executed by your program as a dependency. Most programs don't need a CLASSPATH at all. Those that do use it need a different CLASSPATH for every program, so you will get no end of confusion if you have a System CLASSPATH. Also, a poorly set system CLASSPATH can make it impossible to find your ordinary java folder.
What is CLASSPATH and why shouldn't I set it?
Campbell Ritchie wrote:Very briefly, what I personally would do:-
Don't use NotePad; download a decent text editor for programming; if I ever use Windows, I like NotePad++.
When you open the command line, give it the following instructionsYou can choose a different name for your directory, and you only need line 1 once, but use line 2 whenever you have any more work. You can create as many subdirectories as you wish. That keeps all your work in one place. Don't go into your Java® installation folder.
Make sure to update your system PATH to put your Java® installation folder as its first entry, and don't set a CLASSPATH.
The simplest way to run a single‑file application is java MyJavaFile.java. You are allowed several classes in the same file, but the runtime will require a main() method in the first class written. The procedure is different if you have multiple files.
If you get any error messages, find a good forum to ask about them. I recommend this forum.
Campbell Ritchie wrote:To the best of my knowledge, nowhere. I think they are deleted if you use single file execution.
The OP asked about the java command, not javac. As you said, the javac command puts the XXX.class files in the current directory unless other options are used.
Tim Holloway wrote:. . . What???
The javac command . . .
Yes, the command OP asked about is a sort of interpreted Java®. The earlier versions of single file execution would fail if there were XXX.class files to confuse things. That is what I thought the OP meant when he said there were no XXX.class files after running the java command.
Campbell has been using interpreted Java a lot lately, I think, and the rules are a bit different there. . . ..
Tim Holloway wrote:I think when the difference is whether classes get retained or not goes beyond mere hair-splitting, so it's good to be clear on which mode of operation is actually in effect.
the java command wouldn't work
Yes, the single file execution technique only works if the XXX.java file hasn't been compiled to XXX.class files first. I thought that requirement might have changed for more recent Java® versions, but that is obviously not so. You could try deleting the XXX.class files.
Antonio Moretti wrote:. . . the java command wouldn't work because there was already a class file.
You should of been able to do it with just
Norm Radder wrote:Yes, I understand about the PATH variable.
I have several versions of the JDK and JRE on my PC. The PATH does not point to JDK14.