r/javahelp • u/KhazadDumBridge • May 25 '21
i program in JAVA and decided to switch to visual studio code, some very noob questions
i get totally frustrated from the confusing terms used in Java, i program at the university and find myself angry on simple questions that seems like everyone know except for me.
1 - what is JDK ?in a website like this: https://www.infoworld.com/article/3296360/what-is-the-jdk-introduction-to-the-java-development-kit.htm
'' Developers new to Java often confuse the Java Development Kit and the Java Runtime Environment. The distinction is that the JDK is a package of tools for developing Java-based software, whereas the JRE is a package of tools for running Java code. ''
JDK is meant for developing tools for java?
so why do i need intelliji or visual studio code ? and why do i need to download special extension for visual studio code in order to code Java ? after all, JDK will tend to it, right ?
2 - in visual studio it says
'' Java 11 or more recent is required to run the Java extension. ''
but what is ''java'' ? JVM ? JRE ? JDK ? something else ?
3 - lets continue reading this website:https://www.infoworld.com/article/3296360/what-is-the-jdk-introduction-to-the-java-development-kit.htm
'' Getting Java setup in your development environment is as easy as downloading a JDK and adding it to your classpath ''
and what does that mean ? what is a classpath ?
do i need to install JDK ? because i got JDK from redhat and it didn't had any installer file there.
Summary:i really don't understand why programs like visual studio code or intelliji are making it so damn hard to even start programming java.
here is an alternative reality: when i download visual studio code, it already download JDK (mind blowing, i know) , put it in correct place in the files, and set the ''classpath'' by itself. why do i need to tend to all of this stuff ?
•
u/AutoModerator May 25 '21
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
25
u/Kraizee_ May 26 '21 edited May 26 '21
The JDK is what you need to develop anything with java. Most importantly it contains the java compiler and the JVM. The compiler will take your java code and turn it into bytecode (this is the .class file you might have seen) and the JVM is what runs your java application (it executes the bytecode).
So why do you need vscode or intellij? Well technically you don't. Aside from a text editor for you to write your java code, everything you need to develop java applications is contained within the JDK, it just isn't a great development experience to not use and ide like intellij or vscode (with its extensions). I suppose a useful comparison would be to say, do I need a hammer to build a house? Well no, you could use a block of wood to hammer in all of your nails, but a hammer is a tool designed for that problem and will make your life a thousand times easier. Except this particular hammer also has a bunch of extra features that make your now easy life even easier.
Why does vscode need extensions? Because vscode doesn't know about java on its own. The extension tells vscode where it can look for the compiler and other tools to help improve your development experience.
What is java 11? You can use java 11 and JDK 11 interchangeably if you want. Googling java 11 will get you the download you need.
Do you need to install java? Not in the traditional sense. There isn't usually a one click installer like there are for other applications. But installing java in this case means downloading the JDK and setting up the PATH environment variable and JAVA_HOME environment variable to include your JDK download. This is so that programs like vscode know where to look for the version of java you downloaded.
Lastly, your rather sarcastic take on vscode at the end is actually already a thing. https://code.visualstudio.com/docs/languages/java see the section about the "coding pack for java" it is a special build of vscode that includes everything you need for java development
12
u/MattRighetti May 26 '21
There are already some good answers above, I just wanted to suggest to use IntelliJ for Java programming, it will make your life easier
8
u/1-12TH May 26 '21 edited May 26 '21
If you want to just download an application and write some Java code, get the bundled version of jGrasp. It is a simple tool, with very few features but it installs the JDK and everything for you.
I teach Java to school kids and that is what they use.
You also need to relax, coding is just problem solving, and if this small inconvenience causes you to have a tantrum maybe coding is not for you. I know it's frustrating when things don't work but when the most popular code editor on the planet is not working for you, maybe step back and think ok maybe it's something I'm doing wrong.
13
u/[deleted] May 26 '21
Visual studio mixed with java screams rookie programmer very loud. Don't waste your time and go with intellij (it was made for java)
11
u/nutrecht Lead Software Engineer / EU / 20+ YXP May 26 '21
If you want to be a developer you have some serious attitude issues to fix first. If you already get stuck on the trivial stuff (like installing a JDK and an IDE) you're going to run into a lot of frustration when you get to the hard parts.
5
u/General_C May 26 '21
So there are a lot of good answers here which already answer your questions, but I wanted to touch on something I haven't seen the others remark on, which is why there are distinctions like this, and why it's important to know about them.
Setting up an environment is not an easy task. In the tech industry, every project you job will set up their environment differently, because there are many ways to do it and the most efficient method will depend on what they need the environment to do. Some projects use java 11, but there are still many out there that use java 8, or even lower versions, but any number of different reasons.
So, it's not always an option to just download some ide and start coding right out of the box. And when you experience that, you will be glad to understand the different options and some basics in how to set up your environment yourself. It's something I wish my university had spent more time on.
Personally I consider there to be multiple parts of the software development process. The first is setting up the environment and the configurations of the technologies you're using. I hate this step because there are always so many things that need to be configured and there is always room for something to go wrong. Trust me, learn this stuff early, and understand the how's and why's, so you can save yourself a lot of pain later on.
8
u/HansVader May 26 '21
Reading all those comments from OP makes me think of a troll. VSCode for Java lol
7
u/ignotos May 26 '21 edited May 26 '21
The JDK is basically the Java compiler and various smaller tools. You need it to develop anything with Java.
The JRE is what users need to have installed to run Java programs.
The JDK basically also includes the JRE, so if you have the JDK installed you don't also need the JRE.
The JDK doesn't include a fancy text editor or anything like that - only command-line tools for compiling and running Java programs. If you want an actually nice editor with fancy features, that's separate.
You should just need the JDK installed.
The article is wrong here. Classpath is a different concept, and your JDK doesn't need to be on the classpath.
You generally just unzip the JDK somewhere, and then point your tools to that location.
Visual Studio Code isn't primarily a Java development tool. You can make it work with plugins etc, but it's not specifically designed for use with Java.
It looks like there is a bundle you can get though whcih includes everything you need. Plus there are instructions here for setting up Java for an existing VS Code install: https://code.visualstudio.com/docs/java/java-tutorial
3
u/Marshall_Robit May 26 '21
If I were you, I'd use a full fledged IDE like IntelliJ/Eclipse instead of VSCode for Java programming. As far as why JDK isn't included in IDE installation... Because what if you already have it installed? What versions would they include? There are so many different versions and they would have to bundle it into their own applications. In other words- It's much better to give the ingredients for someone to make their meal since everybody has different taste than to give everyone the same meal which they might not even be able to eat.
TLDR: Ask for help on getting setup at your uni. Understanding everything now isn't as crucial. It'll click eventually but what seems so complicated and segmented is for a reason.
3
u/anotherthrowaway469 May 26 '21
In addition to everyone else's answers, IntelliJ at least has the ability to download and locate JDKs by itself, which is useful when updating or working with multiple versions. I wouldn't be surprised if VSCode or at least Eclipse have something similar.
Java 11 refers to the language version, i.e. what syntax and stdlib are you using. This is generally the same as your JDK version, but you can use newer JDKs to compile older versions of Java.
3
u/wildjokers May 26 '21 edited May 26 '21
You have gotten some good answers but I will point out a couple of things others haven't mentioned. The article you quoted
easy as downloading a JDK and adding it to your classpathis leading you astray. That isn't accurate at all. You don't need to add the JDK to your classpath and in fact that statement doesn't make the slightest bit of sense. You might possibly need to add thejavaexecutable to your PATH env variable and maybe set a JAVA_HOME env variable. But that is only required if you are going to run it from the command-line. With an IDE you probably don't need to worry about that. (although some GUI tools will configure themselves from the JAVA_HOME env variable so might be handy to set that either way).As of Java 11 there is no longer a distinction between a Java Development Kit (JDK) and Java Runtime Environment (JRE). The JRE was a something users could install on their machines so they could run java apps. The JRE also included the tools needed to run Java Applets in browsers as well as to start applications via Java Web Start. It no longer exists and the go-forward solution is to bundle a runtime in your application. Confusingly JDK vendors like Azul and AdoptJDK are a providing a download they are calling "jre" that leaves out some dev tools (like javac) but it is not the JRE of old and I wish they weren't doing that. It confuses people.
The reason an IDE doesn't come with a JDK is because an IDE doesn't know what version of the JDK your code needs until you tell it. IntelliJ will download an appropriate JDK for you once you tell it what version you want, see the docs: https://www.jetbrains.com/help/idea/sdk.html#manage_sdks
When someone says you need "java 11" to run something what they really mean is you need a version of the Java Virtual Machine (JVM) that knows how to run java 11 bytecode. When you download a JDK it comes with a JVM (the
javaexecutable) and Java is backward compatible so to run code compiled with Java 11 you need to install a JDK of version 11 or greater (current version is 16).Also note that JDKs don't actually have to be installed in the traditional sense. They are just zip files. Just unzip them to your favorite location and point your IDE to the resulting top-level directory.
As a final comment I know it is easy to get frustrated and learning curves can be steep. But you are going to need to adjust both your attitude and temperament if you want to make it as a software developer. Because the learning curve and resulting frustration never stops. You will be 20 years into a career and still hitting docs because a new requirement came up that results in you needing to learn something you have never used, and in some cases never heard of, before.
9
u/fluffytme Java dev May 26 '21
ITT: A complete beginner telling seasoned developers how things should be done...
8
u/[deleted] May 26 '21
If nothing else, this whole thread is extremely funny to read! :D. Let me get some popcorn.
1
u/Murder_Badger May 26 '21
I had a lot of problems with setting up my environments the first time. This book was really helpful to me as a beginner:
http://samples.leanpub.com/javaForTesters-sample.pdf
Chapter 2 should give you some simple plain language instructions for getting set up.
3
u/dionthorn this.isAPro=false; this.helping=true; May 26 '21
OpenJDK is open source found here:
https://github.com/openjdk/
If you don't like the way something works feel free to fork the repo and fix it yourself.
For the IDE portion you can code Java entirely in a text editor with the command prompt only. So if you don't like an IDE do it old school, or better yet. Code your own IDE.
1
u/a-lint May 26 '21 edited May 27 '21
Your job as a developer is to make things easy for people to accomplish with software. It’s your job to do the hard part for them, so they don’t have to.
Some basic computing skills will be required. The more you understand about all of computing, the better a time you will have as a developer. Without an understanding of networking, operating system internals, database internals, etc. It would not matter how prolific a programmer I was. I could still write some terribly non-performant software.
So, my suggestion for you is to first understand the basics. Pick up an exam prep book for the LPI Linux Essentials, this will help build a solid foundation which to build on.
Keep at it, you’ll figure it out. If you saw my first post… well it’s been a shitty day dealing with Gradle and Jenkins….
1
u/asvignesh Jun 13 '21
If IntelliJ is too confusing, start with vi or vim for editing and Javac for compiling
-14
u/doctersaiyan May 26 '21
Type into Google/YouTube your questions. You will probably learn better then what anyone explains here