Hajile Latni

Greenhorn
+ Follow
since Sep 04, 2019
Hajile likes ...
Java Netbeans IDE
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
1
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Hajile Latni


Thank you everyone!
2 weeks ago

Carey Brown wrote:Delete 1 & 2. The 3rd one is ok but there's a better way. First, create a brand new environment variable named JAVA_HOME and set its value to C:\Program Files\Java\jdk-12.0.2

Then, modify your path so that this is THE VERY FIRST entry:
%JAVA_HOME%\bin

This helps in two ways: 1) it means that next time you install a new Java release you'll only need to modify JAVA_HOME, and 2) some applications, such as Eclipse depend on JAVA_HOME.



It Worked!!

C:\Users\Eli\Documents\Programming\Java>java -version
java version "12.0.2" 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)

C:\Users\Eli\Documents\Programming\Java>javac Main.java

C:\Users\Eli\Documents\Programming\Java>dir
Volume in drive C has no label.
Volume Serial Number is 1EDF-1F00

Directory of C:\Users\Eli\Documents\Programming\Java

09/06/2019  12:21 PM    <DIR>          .
09/06/2019  12:21 PM    <DIR>          ..
09/06/2019  12:22 PM               413 Main.class
09/05/2019  08:46 PM               109 Main.java
              2 File(s)            522 bytes
              2 Dir(s)  674,127,613,952 bytes free

C:\Users\Eli\Documents\Programming\Java>java Main
Hello World

Thank you so much!!!
2 weeks ago

Campbell Ritchie wrote:

Hajile Latni wrote:. . . I have jre 1.8.0_221 installed before I have installed jdk-12.0.2 and I haven't uninstalled jre 1.8.0_221
then when I type java -version in cmd 1.8.0 always shows up and not 12.0.2

Please adjust your PATH so it points to Java12 first, and remove the Java8u221 part from your PATH. Otherwise, when you compile code in Java12 and try to run it as Java8, you will suffer exceptions.



So I checked environment varibles and there are three paths that has java in it


which ones should I remove?

Have you managed to get your code to execute?

No
2 weeks ago

Junilu Lacar wrote:Also, post the code you have in Main.java so we can see if there is any problem we can point out there.




It's just a basic code since I just started
2 weeks ago

Junilu Lacar wrote:Also, what version of Java are you using? You can find out by running this command:
> java -version



C:\Users\Eli\Documents\Programming\Java>java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

The thing is I have jre 1.8.0_221 installed before I have installed jdk-12.0.2 and I haven't uninstalled jre 1.8.0_221
then when I type java -version in cmd 1.8.0 always shows up and not 12.0.2
2 weeks ago

Campbell Ritchie wrote:

Earlier today, I wrote: . . . . . .

I was mistaken; sorry. that should read I thought it is only Java12 that will allow you to write java Main.java, but only under special circumstances including there not being a Main.class file.

Sorry; I missed the error of including the extension ….java in the instruction. Maybe your code will work if you miss out the extension.



C:\Users\Eli\Documents\Programming\Java>java -cp. Main.java
Unrecognized option: -cp.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

C:\Users\Eli\Documents\Programming\Java>echo %CLASSPATH%
%CLASSPATH%

C:\Users\Eli\Documents\Programming\Java>java -cp. Main
Unrecognized option: -cp.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

Did I type anything wrong?
2 weeks ago
C:\Users\Eli\Documents\Programming\Java>javac Main.java

C:\Users\Eli\Documents\Programming\Java>dir
Volume in drive C has no label.
Volume Serial Number is 1EDF-1F00

Directory of C:\Users\Eli\Documents\Programming\Java

09/04/2019  09:49 PM    <DIR>          .
09/04/2019  09:49 PM    <DIR>          ..
09/04/2019  09:49 PM               413 Main.class
09/03/2019  04:19 PM               109 Main.java
              2 File(s)            522 bytes
              2 Dir(s)  677,906,145,280 bytes free

C:\Users\Eli\Documents\Programming\Java>java Main.java
Error: Could not find or load main class Main.java

I don't know what seems to be the problem. The class file is there but it says it couldn't find it
2 weeks ago