4 ms·
I’ve tried more than once to learn Java I find it very confusing. This website resolves one of the issues. The other issue I have is that most Java tutorials us
by Decabytes 5y ago
I’ve tried more than once to learn Java I find it very confusing. This website resolves one of the issues. The other issue I have is that most Java tutorials use IntelliJ, or some other IDE, which makes it difficult to figure out what a non IDE workflow actually looks like, some managing dependencies is confusing.
I wonder if c# and mono is better in this respect
- Something1234 5y agoI think most languages have a really difficult to configure environment if you mess it up or need to keep multiple versions around. Windows is especially bad about it because of the java_home variable. Mono is a mess to configure on Linux, or at least the last time I tried it to learn F#. Java is actually nice in that a lot of distros are packaging a version manager for it. Arch and centos lead the pack in this. Although cent continues to be a mess about how many jdks and Jres are available.
- gadrev 5y agoC# in mono has the csharp interactive prompt, and you can also use it to run script files (like .csx). Java often uses IDE but there are tools to run a REPL. Groovy had this before Java got it. You can use it to write Java, since Java code is Groovy. It comes with a GUI console into which you can type and evaluate too, or you can write script files and run them. It's not as fashionable nowadays as it used to be (now it's Kotlin, Scala, etc.) but it works great and can be useful for learning Java too.
- the8472 5y agojava itself ships no build and dependency management tools. So you get either the built-in stuff that IDEs offer or use maven, gradle, ant. For toy programs you can also invoke javac directly but as it grows it quickly gets as impractical as compiling large C codebases by hand.
- AmpsterMan 5y agoWhat programming language are you comfortable with? I'd say syntactically Java is fairly simple and at least superficially similar to C/C++. Environment wise, it's definitely very large and oriented toward "powerful but complex" rather than "simple and orthogonal". For build and dependency management systems, Gradle or Maven are your tools. I personally prefer Gradle since it uses a programming language for it's configuration, rather than xml. There is definitely a lack "end-to-end" tutorials that don't rely on some form of tooling support. I would love to see more content on how to make a Java program with nothing but an editor and a command line, but I suspect there isn't much of a need for that. Java's tooling is exceptionally good, it's libraries mature and robust. Part of the reason every tutorial out there uses an IDE is because through quirks of history Java is basically an Enterprise programming environment where "Build the Right Thing" predominates over "Worse is Better". EDIT: There is a REPL included with each JDK after 9 called JShell. It's useful if you just want to get up to speed or if you want to test something quickly.
- npteljes 5y agoThe strongest plus I could say for Java is that it's a stable workhorse that pays the bills, and that the tooling is pretty good. Non IDE workflows don't exist practically, as a curiosity it's nice to compile something "by hand", but the knowledge is nonessential. Switching from one IDE to another is not that big of a deal, workflow-wise, you shouldn't worry about it. As a side note, I appreciate that we have multiple tooling for Java. It doesn't sit well with me when the whole language, and its IDE and compiler and everything is bundled up in one package and that's all you have.
- jamesfinlayson 5y agoFor non-IDE workflow use the Gradle dependency management tool and task runner - you can use javac on its own but for any non-trivial application the command line arguments will get very long.
- kaba0 5y agoForget about this website, just download the most recent OpenJDK version and get at it! As for IDEs, I do recommend IntelliJ for writing the code, but in case you want to understand what happens behind the scenes, you can compile the source code directly in the terminal with `javac YourClass.java`, or *.java, depending on how many files you have. It will by default place the resulting files in the current directory with the convention of creating directories for packages. If you had no package keyword in your files it will result in a simple YourClass.class file that you can run with `java YourClass` (do note that you run classes, not the file itself). If you had something like com.example as a package, it will be placed under WORK_DIR/com/example/YourClass.class. It should be run from the current work_dir though! The reason for that is the notion of a class-path, analog of the PATH variable of unix systems. It lists the package-aware class files, and defaults to the working dir, meaning it will find com.example.* files from here, but not elsewhere. Dependencies are just that, they get concatenated to this class path and thus will be included. EDIT: You can also just issue `java YourClassWithMain.java`, it will compile and run your class in one go