DEV Community

loading...
Cover image for JAVA WITH NOTEPAD

JAVA WITH NOTEPAD

amritanshu profile image Amritanshu Dev Rawat ใƒป1 min read
  • Create Notepad

How to create Notepad?

Right Click > New > Text Document

OR

touch programName.txt [only for pro people]

image.png

  • Give some name to file

image.png

  • Open File

How to open File?

Right Click on file > Open

OR

Just double click on file

image.png

Write some java code

How to write Java Code?

Learn From Youtube or Udemy

image.png

Save file with programName.java extension

How to save with java extension?

File > Save as > programName.java

image.png

image.png

  • Open CMD

If you don't know how to open cmd in current directory visit:

https://newgendeveloper.hashnode.dev/how-to-open-cmd-in-current-directory

Type

javac programName.java
Enter fullscreen mode Exit fullscreen mode

image.png

it will give you a new file programName.class file [Compiled version]

Then Type

java programName
Enter fullscreen mode Exit fullscreen mode

image.png

Twitter

https://twitter.com/NewGenDeveloper

Discussion (35)

pic
Editor guide
Collapse
baenencalin profile image
Calin Baenen

You really shouldn't use notepad, it wouldn't even bother to catch any errors.
While it IS a nice tutorial, I'd recommend at the very least using VSCode. While it's mediocre for a lot of people (and I kinda like it), it at least has basic support for syntax highlighting, and intellicode.

For a beginner just wanting to test, yeah, it is nice, if you want to dip any further than "Hello, world!" though, you gotta at least install a bare bones IDE.

This wasn't necessarily for you (or here to make you feel bad), OP, this is more of a tip to anyone who's followed this, or is following this tutorial.

Collapse
darkwiiplayer profile image
DarkWiiPlayer

You're probably missing the point. Nobody does any serious programming in notepad, but it's nice to have tried it once. So many people learn programming in an IDE and never develop any understanding for the tools that are doing the work behind the scenes.

Here's a short story to underline this point :D

Collapse
amritanshu profile image
Amritanshu Dev Rawat Author

Behind the scenes are important, but these day new mentors forgetting to mention that, and all the kids want to build cool AI, App, Website Project but when ask them how this thing work they be like click on that play button ๐Ÿคฃ

Thread Thread
darkwiiplayer profile image
DarkWiiPlayer

I have yet to find a programming language where it's not beneficial to learn and use the commandline tools (compiler, interpreter, etc.)

Thread Thread
amritanshu profile image
Thread Thread
baenencalin profile image
Calin Baenen

I know this is off topic, but, whatever fucking happened to it just being the language, and the tools the language provided to you when you installed it (i.e. the command line tools).

Now, for things like Java, we have Maven, Gradle, and this other BS I just don't get the purpose of having.

Thread Thread
thefern profile image
Fernando B ๐Ÿš€

Those tools are for libraries/package management, pretty much all languages have them. Python=pip, Javascript=npm, Java/Kotlin=Maven/Gradle, ObjC/Swift=Cocoapods, and so on. Essentially you write a dependency file with all the packages you need, and then sync. These tools will download everything for you. So if you need 10 jar lib files, it will be done for you without you having to manually download each jar and configure it in the project settings path. They might look like BS at first, but once you learned their purpose you'll never go back to manual downloading of libs.

They really matter when you have a big project, and you don't want to reinvent the wheel if a library is already built.

Thread Thread
baenencalin profile image
Calin Baenen

What about compiling/running. That (by itself, not accounting for libraries) should be done through the langs VLI, right?

No? Why the fuck not, that's how it USED to work, and I still need to catch up, so let me use my "cave man" methods.

Collapse
patarapolw profile image
Pacharapol Withayasakpunt • Edited

And even ignoring most advanced features, NotePad is very limited at Undo.

I recommend minimum Gedit or NotePad++. (or even Nano / Vim)

MS Word, yes someone do use, is OK at features, but bad at monospace and unformatted text. Even Markdown is better.

NotePad is substandard software to me.

Collapse
neilgall profile image
Neil Gall

Notepad is definitely going too bare bones but when learning something new - particularly a new language or API - I always drop the IDE and use a good text editor. It forces you to look up and read the docs, type out things in full and generally think a bit more about the details of what you are doing rather than coding on IDE autopilot.

Collapse
baenencalin profile image
Calin Baenen

Usually, for IDEs that support it, though, they have docs (as Java to Javadoc) integrated, so you can read what they do.

Sure, it means you won't remember it, since you can just go straight to what you're looking for, but still, once you read a method/class' doc, you should know what it does (if the name/arguments weren't already enough of a hint for the puny brain reading the code).

Thread Thread
thefern profile image
Fernando B ๐Ÿš€

zealdocs.org/ is a great tool for docs. I think mac is dash docs. kapeli.com/dash

Collapse
thefern profile image
Fernando B ๐Ÿš€

Yeah I wouldn't make my worst enemy code in notepad, maybe notepad++, just maybe lol.

Collapse
amritanshu profile image
Collapse
sergix profile image
Peyton McGinnis

I completely agree. What baffles me though is how many college introductory programming courses still use Notepad to write source code in-class...

Collapse
amritanshu profile image
Amritanshu Dev Rawat Author • Edited

I have been working with VS Code, Inteli J, Eclipse and other tools too.. but when it comes to practice i always prefer notepad.. and yes you are also right...

Collapse
baenencalin profile image
Calin Baenen

"practice".

Collapse
hugekontrast profile image
Ashish Khare๐Ÿ˜Ž

Can't say useful. Still don't understand the need? ๐Ÿ˜…๐Ÿค”

Collapse
amritanshu profile image
Amritanshu Dev Rawat Author

in one of my interview, IDE was banned ๐Ÿ“Œ

Collapse
thefern profile image
Fernando B ๐Ÿš€

Off-topic, but that's kind of awful, no? Why are interviews so unrealistic, you'll never code a product in notepad. Even if it was done just to see if you can compile Java, that's still a bad interview question imo.

Thread Thread
amritanshu profile image
Amritanshu Dev Rawat Author

they just want to know how you solve a problem in difficult situation and maybe how much patience one got ๐Ÿ“Œ

Thread Thread
hugekontrast profile image
Ashish Khare๐Ÿ˜Ž

I'll die laughing on this one. Bro they tested you if you know the language or you are just stuck hitting "run" in IDEs. Asking you to code in notepad doesn't mean to put you in difficult position. And nothing related to patience. Still nice try putting the post up.

Thread Thread
amritanshu profile image
Amritanshu Dev Rawat Author

I am lazy enough and don't want to explain 100 lines why they do that.. so that comment came from my lazy mind..

Collapse
rkennela2 profile image
Ryan Kennel ๐Ÿถ

IDE banned? Why not also tie your right hand behind your back?

Thread Thread
amritanshu profile image
Amritanshu Dev Rawat Author

lol, maybe when i become senior sde.

Collapse
hugekontrast profile image
Ashish Khare๐Ÿ˜Ž

Hahaha๐Ÿ˜‚ Yeah that's why study languages and their uses, never make dips on ide.

Collapse
darkwiiplayer profile image
DarkWiiPlayer

It's amazing to read how strongly people react to the idea of using notepad for coding. Of course it's inconvenient, that's why code editors exist, after all. But if you know what you're doing, it doesn't make that much of a difference. Lack of syntax highlighting isn't all that bad if the code is well-structured. No autocomplete needs you need to know your tech instead of "browsing" it.

In short: Programming in notepad means you have to actually know how to program.

When I learned programming, it was using an IDE. Later, when I learned Java, it was also using an IDE. When I started learning C, guess what: IDE. At some point, driven by curiosity, I started playing around with the compilers much more, writing code as text files (yes, even in notepad) and compiling them by hand. It didn't take long for me to just ditch IDEs entirely and go on an editor journey that would ultimately lead me to Vim, and I haven't looked back once.

And to those who are bewildered at the mere suggestion of using notepad: try it. It's good practice, and you might get a better understanding of how much a proper IDE actually does for you.

Collapse
amritanshu profile image
Amritanshu Dev Rawat Author

ya, that's the thing, you only get to know the actual thing when you play with it.

Collapse
vepo profile image
Victor Osรณrio

Why tag this post with #javascript?!?!?! Java is for Javascript the same that car is for carpet.

Collapse
amritanshu profile image
Amritanshu Dev Rawat Author

without java you can't pronounce javascript.. actual answer: they want 4 tags.

Collapse
ducaale profile image
Mohamed Dahir

Nitpick: create notepad should be create a .txt file. This is important because not everyone has their computer configured to open .txt files with notepad.

Collapse
amritanshu profile image
Amritanshu Dev Rawat Author

Right click > New > "Text Document" (text document by default set to .txt )

Collapse
rkennela2 profile image
Ryan Kennel ๐Ÿถ

This is literally how I learned to code Java in 1997. Letโ€™s just be thankful that IDEs exist today.

Collapse
amritanshu profile image
Collapse
havryliuk profile image
Oleksandr

You wonโ€™t be able to run javac without JDK installed which is not covered in this tutorial.

Collapse
amritanshu profile image
Amritanshu Dev Rawat Author

you can't write java code without learning java, and what you saying is same as you can't write code without keyboard.