Jump to content

Make Java syntax work in CMD?

Kanna

Hey so I have ran into this issue that java syntax doesn't work in the cmd, but I fixed it before, but accidentally removed the path to regular CMD so when I added it back ofc java doesn't work. So my simple question is how can I add the java path to environment variables at the same time as CMD path?

Reminder⚠️

I'm just speaking from experience so what I say may not work 100%

Please try searching up the answer before you post here but I am always glad to help

Link to comment
Share on other sites

Link to post
Share on other sites

Do you mean you can't start a Java program from the terminal by typing "java -jar minecraft.jar" or similar? You need to add the Java bin-directory to the "PATH" environment variable: https://www.geeksforgeeks.org/how-to-set-java-path-in-windows-and-linux/

 

Using Java syntax would imply you're writing a Java program in CMD, which seems unlikely.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Eigenvektor said:

Do you mean you can't start a Java program from the terminal by typing "java -jar minecraft.jar" or similar? You need to add the Java bin-directory to the "PATH" environment variable: https://www.geeksforgeeks.org/how-to-set-java-path-in-windows-and-linux/

 

Using Java syntax would imply you're writing a Java program in CMD, which seems unlikely.

Yeah that's what I'm trying to do, thanks for the link to a better guide the other one I used said to name path (which overwrites). Also about the syntax thing, It was the word used here by my teacher for the commands "ping" and "attrib" and such, so I made the assumption lol

Reminder⚠️

I'm just speaking from experience so what I say may not work 100%

Please try searching up the answer before you post here but I am always glad to help

Link to comment
Share on other sites

Link to post
Share on other sites

On 12/2/2022 at 6:53 PM, Eigenvektor said:

Do you mean you can't start a Java program from the terminal by typing "java -jar minecraft.jar" or similar? You need to add the Java bin-directory to the "PATH" environment variable: https://www.geeksforgeeks.org/how-to-set-java-path-in-windows-and-linux/

 

Using Java syntax would imply you're writing a Java program in CMD, which seems unlikely.

So I made the mistake of actually not checking function before commenting, and after following that guide it still doesn't workimage.png.ce1d2187e729418db1f60be599c03eca.pngimage.png.6371284f7ea36bed18ed9017f2b687f4.png

Reminder⚠️

I'm just speaking from experience so what I say may not work 100%

Please try searching up the answer before you post here but I am always glad to help

Link to comment
Share on other sites

Link to post
Share on other sites

10 minutes ago, Kanna said:

So I made the mistake of actually not checking function before commenting, and after following that guide it still doesn't workimage.png.6371284f7ea36bed18ed9017f2b687f4.png

You also need to adjust your PATH environment variable after creating the JAVA_HOME one:

Lightbox

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Eigenvektor said:

You also need to adjust your PATH environment variable after creating the JAVA_HOME one:

Lightbox

It would be the PATH, on system variables correct? if so the edit button is grayed outimage.png.b03b9a2e390cbfe4d6d7e506d2907ade.png

Reminder⚠️

I'm just speaking from experience so what I say may not work 100%

Please try searching up the answer before you post here but I am always glad to help

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Kanna said:

It would be the PATH, on system variables correct? if so the edit button is grayed outimage.png.b03b9a2e390cbfe4d6d7e506d2907ade.png

Yes, correct. You'd need to run as an administrator to be able to update this.

 

As an alternative, you should be able to start Minecraft like this:

%JAVA_HOME%\bin\java.exe -Xmx4096M …

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Eigenvektor said:

Yes, correct. You'd need to run as an administrator to be able to update this.

 

As an alternative, you should be able to start Minecraft like this:

%JAVA_HOME%\bin\java.exe -Xmx4096M …

How do I navigate to it so I can run as an administrator?

Reminder⚠️

I'm just speaking from experience so what I say may not work 100%

Please try searching up the answer before you post here but I am always glad to help

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Kanna said:

How do I navigate to it so I can run as an administrator?

Can you try opening cmd as admin (right click, run as administrator), then open

sysdm.cpl

 

Spoiler

image.png.003d636261410a8e743da996a797b872.png

image.png.47aa23366f8f735941d763393fbc7a7c.png

 

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

33 minutes ago, Eigenvektor said:

Can you try opening cmd as admin (right click, run as administrator), then open

sysdm.cpl

 

  Hide contents

 

Yep got it open now that way, now I'm just looking on how to get to the menu you showed, I clicked PATH and edit which was not correct in my caseimage.png.e6d7609f4bc0bd127f7d1e8f7f141e27.png

Reminder⚠️

I'm just speaking from experience so what I say may not work 100%

Please try searching up the answer before you post here but I am always glad to help

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Kanna said:

Yep got it open now that way, now I'm just looking on how to get to the menu you showed, I clicked PATH and edit which was not correct in my case

I just double click or click Edit and the editor shows (Windows 10).

 

I just checked on another machine and I have Path both for my variables and system variables. You could try adding path to your variables and then just adding the path for Java there.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

27 minutes ago, Eigenvektor said:

I just double click or click Edit and the editor shows (Windows 10).

 

I just checked on another machine and I have Path both for my variables and system variables. You could try adding path to your variables and then just adding the path for Java there.

I figured out what I had to do to get that menu to show, I had to type both and separate with a ; so now I got that menu with both in it. But the negative thing here is that java is still

not recognized after a restart, should I just give up and use the tip you gave earlier?

image.png.3866eabadffbd4e5a761e2fafb2751e9.png

edit : I think I solved it perhaps, I didn't set it to the bin directory, I think I missed that part in the guide sorry for all the confusion done lol it works now

Reminder⚠️

I'm just speaking from experience so what I say may not work 100%

Please try searching up the answer before you post here but I am always glad to help

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Kanna said:

edit : I think I solved it perhaps, I didn't set it to the bin directory, I think I missed that part in the guide sorry for all the confusion done lol it works now

Was just about to point that out 😄

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, Eigenvektor said:

Was just about to point that out 😄

Yeah, that mistake was on me lol. Should have just copied the path I used when it worked once 

Reminder⚠️

I'm just speaking from experience so what I say may not work 100%

Please try searching up the answer before you post here but I am always glad to help

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×