+ 3
Running Java on Computer?
How do I go about running my java program i'm writing on my computer so that it reads the inputs differently rather than inputting all the inputs before running the code? I was told to put it in a folder on my desktop, open cmd, change the directory to that folder and type javac Program.java. Then to type java Program. I just get errors though. I looked it up and i'm not sure how to go about editing my Class in my environmental variables. And I'm not sure how to go about adding a classpath because I don't have one listed at all in my environmental variables. Please help?
13 Answers
+ 2
This is the official guide to add Java to PATH:
https://java.com/en/download/help/path.xml
You sound like you are stuck at step 3, which you are supposed to find the PATH environmental variable.
This is a screenshot I found which shows the path variable:
https://www.ghacks.net/wp-content/uploads/2015/09/windows-10-new-environment-variables-editor.jpg
Focus on the window on the background: The bottom part of the window shows a list of "system variables". One of them is the "Path". Double-clicking on that slot will bring up the front window in the screenshot. Now, you should click on "new" on that front window, and add the path to your Java bin folder.
It should be something like this path below. Please check your actual Java installation path as the version may vary:
C:\Program Files\Java\jdk1.8.0_40\bin
After that, confirm everything and proceed with step 5 in the official guide.
+ 2
I had done that already for path. But it doesnt work
+ 2
Also, my jdk is 11.0.1 And my jre is 1.8.0_192
+ 2
I made a class in BlueJ. I compiled it, but I dont see how to run it
+ 2
I just got it to run in bluej. Thank you everybody for the help:)
+ 1
My class is Work. I named my file work and my path is set to my bin. I opened cmd and typed cd desktop. then cd work (I put the .java file in a folder called work on my desktop). Then i typed javac work.java. It created a .class file in the folder with it. Then I typed java work and it gave me this error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: work has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
+ 1
If you are begginer. You should use BlueJ, recommended by Donna, it is very good for begginers
+ 1
I just updated jre. And I got BlueJ, and imported my code, but I can't see how to run it
+ 1
My runtime environment is the highest on the Oracle site
+ 1
Go here https://www.oracle.com/technetwork/java/javase/downloads/jdk-7-netbeans-download-432126.html
accept term, select your system and download and install. Make sure to read through all instructions on the website plus while installing.
When you have netbeans ready open it, open a new java project and copy and paste your code in there. Now you can run it normally with multiple inputs and all...
+ 1
Make a class in BlueJ and copy your code in that class. And run it.
0
I think your JRE is old, plz update it.
0
Now what error java gives? Plz share