-2

I am learning java using notepad(solo runner).is it possible to run all java program using notepad?

ex:applet,inheritance .

when we need to use package?

(I know IDE are available , but i recommend notepad due to some critical circumstances).

Questions are bit silly, but i am learning by my own. so i am using online help.

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
Keerthana
  • 95
  • 4
  • 10
  • 4
    You can't run programm in notepad. – Suresh Atta Feb 01 '18 at 12:05
  • what is the purpose of package?i run the multilevel inheritance using package? but i dont understand the correct usage . – Keerthana Feb 01 '18 at 12:07
  • Just run your program from the command line. – Thomas Feb 01 '18 at 12:07
  • 1
    @Keerthana Don't bombard the thread with multiple questions. One question at a time please. – Suresh Atta Feb 01 '18 at 12:07
  • Your second question should be a separate question but before you post that you should do some research since there are _a lot_ of tutorials/explanations on packages. – Thomas Feb 01 '18 at 12:08
  • 1
    @Keerthana "i run the multilevel inheritance using package" this statement makes no sense. Packages are used to create and maintain a decent overviewable project, and to group related classes – Stultuske Feb 01 '18 at 12:08
  • 3
    You can *write* Java in notepad, and compile and run it from the command line. – khelwood Feb 01 '18 at 12:08
  • i know how to run hello world program. if i use 2 classes then how i compile the program in command line? – Keerthana Feb 01 '18 at 12:17
  • @Thomas thanks for your prompt comment. – Keerthana Feb 01 '18 at 12:23
  • only one of the 2 classes you're using has a main. you have to compile both and run the one that defines main. – cosh Feb 01 '18 at 12:24
  • . please do not give -ve marks, here i am not posting any questions without googling and also you ppl are good in technical. so i am posting for shorting my time to clear about my doubts easily. now i got -3 marks which means i cant post question in next 3days..however thanks for your response for silly questions. – Keerthana Feb 01 '18 at 12:37
  • Lol... get an proper editor, install a firewall and prevent editor to go to the internet. Then burn notepad. The minus 3 is due to the fact you're question belongs to a forum... theire they would have said the same as I did with this comment. /votes to close due to off-topicness in relation to SO rules. – ZF007 Feb 01 '18 at 12:42
  • 1
    Possible duplicate of [How do I run a Java program from the command line on Windows?](https://stackoverflow.com/questions/16137713/how-do-i-run-a-java-program-from-the-command-line-on-windows) – Jasper de Vries Feb 01 '18 at 13:02

4 Answers4

1

You can not run java program using notepad. However you can use command prompt if dont intend to use IDE.

e.g.

javac yourFileName.java // It will create .class file
java yourFileName       // It will run your program and will show output/errors
Turing85
  • 18,217
  • 7
  • 33
  • 58
AbhiN
  • 642
  • 4
  • 18
1

Create a program in notepad and save file as .java extension. e.g as hello.java. Use compiler to run the program from console. e.g javac hello.java and to run use java e.g. java hello.

import java.io.*;
class hello
{
    public static void main(String[] args)
    {
        System.out.print("hello");
    }
}
ZF007
  • 3,708
  • 8
  • 29
  • 48
ACT
  • 147
  • 6
0

Just trying to be a little bit clearer than all the comments to your question: notepad is a simple text editor. To effectively run a Java program, you need to first compile the code you wrote in plain text, which will generate the corresponding Java bytecode, and then execute that bytecode using the JVM (Java Virtual Machine). I'd recommend you read about these 2 components, the Java compiler and the virtual machine.

Regarding the part about packages, they're usually used to group similar or related classes, and to avoid naming conflicts (e.g. you can have class A in package X and class A in package Y, and so you'd reference each one as X.A and Y.A, respectively).

cosh
  • 470
  • 1
  • 4
  • 15
  • thanks, but in applet no main functions and also multilevel inheritance having 2 classes. In IDE we can create multi java class program and import into main function .i am getting an error while i tried to import a.java into b.java using notepad. – Keerthana Feb 01 '18 at 12:22
  • look at it this way, java classes with no main can't be "run", only "used". – cosh Feb 01 '18 at 12:25
  • sure.now i got it. – Keerthana Feb 01 '18 at 12:30
0

First of all, you need Notepad to just write the code and Java to compile/run. IMHO, I think if you just do a search on your own you should be able to find lots of tutorials for getting started with Java :)

I recommend you to go through some good tutorials/books so that you get a good understanding of the language. But just to answer your question, you can go through the below link to create a program in Notepad, compile and run it:

http://www.skylit.com/javamethods/faqs/javaindos.html

You can create simple Java programs using Notepad if you are just getting started or trying things. But it's recommended to use a good IDE like IntelliJ, Eclipse, etc if you are into serious programming as they provide you tons of features.

Rahul
  • 637
  • 5
  • 16