This repository is aimed at providing the students of computer applications at a school affiliated with the CISCE board in India, UAE, Singapore, Thailand & Indonesia, with all the types of java programs which are included in the syllabus for learning / educational purposes. The programs can be commented upon and edited by simple pull requests which shall be approved by the administrator.
To run java code on your device you shall need the JDK, JRE and JVM installed and running on the computer.
Most of the modern day devices come with th JDK ( Java Development Kit ) installed which consists of the Java Runtime Environment ( JRE ) and Java Virtual Machine ( JVM ) built into it, but if your device does not contain it, or is quite old & you're unaware about it, you can click the link here to get redirected to a download page from where you can download and install the JDK for your device, based on your device's architecture which you can find in the system info.
You can simply search up a program you need, open up the source code, copy the same and further paste it into a text editor. It should be noted that you have to save the file with the following file extension:
.javaYou need to get to the 'save as' of the text editor & save the file with this extension only to be able to run it with the help of Windows CMD / Linux Terminal / Mac Terminal.
for me, in Linux Mint, the user ishan@MintyIsh, the execution of the java code begins with first going to the directory in which the java file is stored.
I have a file called Fibonacci.java, stored in the LinDev folder on my Desktop.
public class Fibonacci
{
public static void main(String[] args)
{
int n = 10;
int n1 = 0;
int n2 = 1;
System.out.print("First " + n + " terms: ");
for (int i = 1; i <= n; ++i)
{
System.out.println(n1);
int sum = n1 + n2;
n1 = n2;
n2 = sum;
}
}
}So, to navigate to my desktop in the terminal I shall use the following command called cd .
ishan@MintyIsh:~$ cd DesktopFurther, I will get into my folder LinDev.
ishan@MintyIsh:~/Desktop$ cd LinDevOnce that is done, I write the javac Fibonacci.java statement in Bash to tell the terminal to get my Fibonacci.java file compiled into a .class file.
ishan@MintyIsh:~/Desktop/LinDev$ javac Fibonacci.javaNow you can wait for a while and then type java Fibonacci to see your file running in the Linux Terminal.
ishan@MintyIsh:~/Desktop/LinDev$ java FibonacciThe same javac and java statements can be used in Windows' CMD and MacOs' terminal. However, if you still have a doubt, please refer to the following videos.
click here to see how to run the files in MacOS
click here to see how to run the files in Windows
Before executing the programs, please check if the String argument of java.lang class is present in the main() method else it will will not run
For BlueJ , you can go to the following videos to learn how to deal with the programs.
Running the first program in BlueJ
It must be noted that the class name that you put while making the class and while writing the following statement shall be same and not different in any circumstance.
// name is user-defined
public class [name]Pull requests are welcome. For major changes or additions , please open an issue first to discuss what you would like to change or add into the repository