Edit and run java file on computer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Edit and run java file on computer

Hi everyone, I am a beginner of Java, I am learning and practising, but I don't know how to save a Java code and run it. I have learnt HTML and could edit in Notepad then save with .html extension, then I can open the file easily; however, I save a Java code with .java extension but I cannot open the file. Hope to receive your help.

30th Mar 2018, 1:45 AM
Trần Long Quang
Trần Long Quang - avatar
7 Answers
+ 2
For developing Java on PC, you first need to download both the JRE(Java runtime environment) and the JDK(Java development kit) from Oracle.com, you then need to download an IDE (something like Eclipse or Netbeans) to compile your codes into executable files and to assist you with debugging and all what an IDE is supposed to bring.
30th Mar 2018, 2:08 AM
CHMD
CHMD - avatar
+ 1
I downloaded this link (https://java.com/en/download/win10.jsp) but it didn't help, is it wrong? Will it be OK if I uninstall it and search to download JRE, the JDK and IDE? If possible, can you please send me link of these 3 items to download? I'm just afraid that I download wrong ones.
30th Mar 2018, 2:13 AM
Trần Long Quang
Trần Long Quang - avatar
+ 1
yeah it's ok Java is owned by Oracle so whether you download from java.com or Oracle.com, it's indifferent. As for the download links, I can't really send you the right ones since I dont know whether you have a 64 or 32 bit system. Just refer to a video on YouTube on how to install these and you should be good to go.
30th Mar 2018, 2:20 AM
CHMD
CHMD - avatar
0
Thank you very much, I will search for it.
30th Mar 2018, 2:25 AM
Trần Long Quang
Trần Long Quang - avatar
0
You don't need any IDE just the jdk bundled with the jre. When you installed the JDK, switch in your java folder (where the JDK was installed). There should be a javac.exe and a java.exe, which you can use on your own. Now you just move your .java file in this java folder with the 2 .exe and launch a terminal there. Now you type: javac yourfile.java This generated a .class file: A compiled byte code generated by the java compiler from your .java. To run your byte code type: java yourfile.class This fires up the JVM which interprets (or JIT compiles) your byte code and exexutes it. No need to use an IDE at the beginning.
30th Mar 2018, 5:57 PM
StoneSmasher
StoneSmasher - avatar
0
Why complicate your coding life when you can make it easier, using an IDE is not rocket science. Plus it greatly helps to situate and organize yourself. I'd rather do that early to familiarize myself with the interface of the program. Hit two birds with one stone.
30th Mar 2018, 9:08 PM
CHMD
CHMD - avatar
0
Of course an IDE helps, but don't you want to know what the IDE exactly automates to run a java file?
30th Mar 2018, 9:17 PM
StoneSmasher
StoneSmasher - avatar