Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Stephan van Hulst wrote:But seriously, use the command line tools before you use an IDE. You will then form a much greater understanding for what happens behind the scenes when you eventually use an IDE.
Frank Carver wrote:If you want to run some Java code, first it needs to have a "main" method.
If you class has a main method, you can run it in Eclipse by right clicking on the class name in the "Package Explorer" at the left of the screen, and selecting Run As -> Java Application.
Stephan van Hulst wrote:But seriously, use the command line tools before you use an IDE. You will then form a much greater understanding for what happens behind the scenes when you eventually use an IDE.
Do you know what a compiler is?
Tim Holloway wrote:Note: this thread parallels a similar one: https://coderanch.com/t/753359/ide/type-code-eclipse
If you're still learning Java then it may be too soon to start learning an IDE. IDEs are very complex environments and they can actually interfere with learning how to design and code when you're not yet comfortable with a language and its runtime environment.
First, a note on building. For beginner projects a simple command line or batch script will generally do. As you develop, however, you need a build tool that understand's Java's particular quirks and needs. Although there are several, Maven is about the most commonly-used. Maven encourages a standardized project organization, although I myself was slow to adopt it because it's "magic". Maven is based on goals and there's no way to list what goals a given project requires. You just have to learn the ones you'll need. But that's not as hard as it seems. Maven is a useful skill since many IDE projects themselves use Maven to build with.
Now for editing. The best start is, as we often say, Windows Notepad (or your chosen OS equivalent). It's vanilla text editing with no special support for Java or any other programming language.
The next step up is a "smart" editor. Some of the fancier editing systems have different edit modes that can do things like highlight different language elements, automatically suggest text based on context and so forth. The Emacs text editor is a common favorite, although it has often been described as "an operating system that's only pretending to be a text editor*" and it was designed for keyboards that have extra shift keys that have to be faked on PC keyboards. So while actual text entry is simple, the emacs commands are tied to a bewildering array of CTRL, SHIFT and META (META???). Plus Super and Hyper, but we don't talk about Super and Hyper. Oh, and you can customize Emacs. By writing add-ons in LISP.
Which is what they did to create the Emacs Java-mode plugin.
On the other end of the battlefield is the "vi" editor and its derivatives such as vim. Emacs works in data input mode by default. The vi editor, on the other hand, works in command mode by default. While vi doesn't use a lot of function keys, if you sneeze while in command mode, you've probably accidentally typed in a command sequence with horrible consequences. While many über-geeks swear by vi, ordinary people will probably find it intimidating. But it is a very good option if you're connected to your computer via a 300-baud modem terminal line.
And there are lots of other smart editors around, although I mentioned Emacs and vi because they're available for virtually all Unix and Linux distros.
Once you're comfortable with the language, editing and build, then you're ready to move up to an actual IDE.
IDE stands for Intelligent Development environment. It combines smart editing and build support with test and debugging. The heart of virtually every IDE system is the project, and you can create projects using the IDE command system (such as File/New Project Menu) or import existing projects. Although many IDEs support a flexible directory structure, they also support Maven project structure, so that as you move up you don't have to re-design your Maven projects. In fact, the Maven goal "eclipse:eclipse" when run against a Maven project will automatically create Eclipse metadata for the project. There's also a Maven goal for IntelliJ, which is, unsurprisingly, "intellij:intellij". You can even run both, since the metadata for Eclipse and IntelliJ are in different forms that don't interfere with each other.
The main things you'll see in an IDE is that you have a GUI browse function for your projects, and the editors are very smart indeed, where often they will provide code auto-completion and instant feedbacks on coding errors. Debugging is typically done by creating a run profile that you'll execute to either spin an internal debugging session or to attach to a remote debugging session; the actual debugger for Java is built into every JVM so the IDE's just connect and talk to it in GUI fashion.
===
*Some die-hards really so spend their entire lives in Emacs. It not only edits text, it has web browsing and email capabilities. And a good game of Tetris.
Mark Roberge wrote:
Tim Holloway wrote:Note: this thread parallels a similar one: https://coderanch.com/t/753359/ide/type-code-eclipse
If you're still learning Java then it may be too soon to start learning an IDE. IDEs are very complex environments and they can actually interfere with learning how to design and code when you're not yet comfortable with a language and its runtime environment.
First, a note on building. For beginner projects a simple command line or batch script will generally do. As you develop, however, you need a build tool that understand's Java's particular quirks and needs. Although there are several, Maven is about the most commonly-used. Maven encourages a standardized project organization, although I myself was slow to adopt it because it's "magic". Maven is based on goals and there's no way to list what goals a given project requires. You just have to learn the ones you'll need. But that's not as hard as it seems. Maven is a useful skill since many IDE projects themselves use Maven to build with.
Now for editing. The best start is, as we often say, Windows Notepad (or your chosen OS equivalent). It's vanilla text editing with no special support for Java or any other programming language.
The next step up is a "smart" editor. Some of the fancier editing systems have different edit modes that can do things like highlight different language elements, automatically suggest text based on context and so forth. The Emacs text editor is a common favorite, although it has often been described as "an operating system that's only pretending to be a text editor*" and it was designed for keyboards that have extra shift keys that have to be faked on PC keyboards. So while actual text entry is simple, the emacs commands are tied to a bewildering array of CTRL, SHIFT and META (META???). Plus Super and Hyper, but we don't talk about Super and Hyper. Oh, and you can customize Emacs. By writing add-ons in LISP.
Which is what they did to create the Emacs Java-mode plugin.
On the other end of the battlefield is the "vi" editor and its derivatives such as vim. Emacs works in data input mode by default. The vi editor, on the other hand, works in command mode by default. While vi doesn't use a lot of function keys, if you sneeze while in command mode, you've probably accidentally typed in a command sequence with horrible consequences. While many über-geeks swear by vi, ordinary people will probably find it intimidating. But it is a very good option if you're connected to your computer via a 300-baud modem terminal line.
And there are lots of other smart editors around, although I mentioned Emacs and vi because they're available for virtually all Unix and Linux distros.
Once you're comfortable with the language, editing and build, then you're ready to move up to an actual IDE.
IDE stands for Intelligent Development environment. It combines smart editing and build support with test and debugging. The heart of virtually every IDE system is the project, and you can create projects using the IDE command system (such as File/New Project Menu) or import existing projects. Although many IDEs support a flexible directory structure, they also support Maven project structure, so that as you move up you don't have to re-design your Maven projects. In fact, the Maven goal "eclipse:eclipse" when run against a Maven project will automatically create Eclipse metadata for the project. There's also a Maven goal for IntelliJ, which is, unsurprisingly, "intellij:intellij". You can even run both, since the metadata for Eclipse and IntelliJ are in different forms that don't interfere with each other.
The main things you'll see in an IDE is that you have a GUI browse function for your projects, and the editors are very smart indeed, where often they will provide code auto-completion and instant feedbacks on coding errors. Debugging is typically done by creating a run profile that you'll execute to either spin an internal debugging session or to attach to a remote debugging session; the actual debugger for Java is built into every JVM so the IDE's just connect and talk to it in GUI fashion.
===
*Some die-hards really so spend their entire lives in Emacs. It not only edits text, it has web browsing and email capabilities. And a good game of Tetris.
I wasn't sure that my first post was posted. This one is getting more useful action. Right now I am not interested in command line anything. Sounds more difficult since I have no idea how to run java code in the command line.
Mark Roberge wrote:
Stephan van Hulst wrote:But seriously, use the command line tools before you use an IDE. You will then form a much greater understanding for what happens behind the scenes when you eventually use an IDE.
Do you know what a compiler is?
I have no idea how to run a java program from the command line. Right now I think I might be better off using an ide.
Frank Carver wrote:If you want to run some Java code, first it needs to have a "main" method.
If you class has a main method, you can run it in Eclipse by right clicking on the class name in the "Package Explorer" at the left of the screen, and selecting Run As -> Java Application.
Original code source: https://github.com/patniemeyer/learningjava/blob/master/examples/ch02/HelloJava2.java
Frank Carver wrote:Please enclose all code examples in code tags so they are readable. I have done this for you this time, but it's up to you from now on.
As for your code,. there are still several errors in this class, so you won't be able to run it until it compiles correctly.
Please double-check everything from the original source code, paying particular attention to capital letters and brackets.
When you have no more red error markers you should be able to run your class.
Note, however, that this class references another class HelloComponent2 which you have not included. Without that class your code will not be able to run, either.
In general, you are better trying something such as the classic "hello world" class to test that you understand how to use the tools and can enter, build, and run code successfully. Only then move on to more complex techniques such as graphical interfaces.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Simon Roberts wrote:Since you're starting from scratch, you have many unrelated things getting in your way at the same time. This is a bit dated, but the key concepts haven't changed at all (they've been added to, but you can ignore the new stuff while you're starting). This was written for an older version of netbeans, but I think you'll have a fighting chance of following it through to a first success:
https://docs.oracle.com/javase/tutorial/getStarted/cupojava/index.html
The code is an exact copy
Frank Carver wrote:If your code was compiled by Eclipse it will be in the "bin" folder inside the project, which will itself be inside the Eclipse workspace folder in your home directory.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Frank Carver wrote:If your code was compiled by Eclipse it will be in the "bin" folder inside the project, which will itself be inside the Eclipse workspace folder in your home directory.
If you are working with Eclipse, though, by far the most sensible way to run your code is to get Eclipse to run it, as I suggested in my previous post!
Much later, when you have a completed and tested application, you can export it as an executable jar file so that other people can run it without Eclipse.
Seriously, though, one small step at a time.
Frank Carver wrote:
The code is an exact copy
If the code you originally posted is an exact copy, as in you used the copy-paste function from your web browser, I would stop looking at that website immediately. It is not valid Java. I am talking about the book's website where the author has written working Java code.
If, however, you read it and typed it in yourself, then you need to get used to paying very close attention and double-checking everything.
This is what I am doing
Capital letters and spaces in names are very important
Where you place your brackets is very important, as is the type of brackets you use.
In Java, the filename must be exactly the same as the name of the class (but with .java added)
As everyone else is saying, you need to take one small step at a time and make sure you completely understand that before moving on. In this case that means starting with a very simple, completely self-contained class and making sure you can get that working before you move on to anything else. Try this one:
[code=java]package example;
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
Only when you have that working should you consider trying anything more complicated.
Tim Holloway wrote:
Also, mark, please don't quote entire messages. It's a waste of space and makes posts harder to read. If you quote, quote the specific items you're referring to.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Mark Roberge wrote:
Stephan van Hulst wrote:But seriously, use the command line tools before you use an IDE. You will then form a much greater understanding for what happens behind the scenes when you eventually use an IDE.
Do you know what a compiler is?
I have no idea how to run a java program from the command line. Right now I think I might be better off using an ide.
Which book? I am not quite sure about recommending you move on to GUIs at such an early stage.Mark Roberge wrote:. . . Step 2 is to write code in a window that does essentially the same thing . . . .
I didn't help you myself, but (on other people's behalf) . . . “that's a pleasure.”Thanks for all of the help!
Campbell Ritchie wrote:I am not quite sure about recommending you move on to GUIs at such an early stage.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Mark Roberge wrote:I am new to java. I am going to be taking a class in java, python, and php.
My problem is that Java is new to me and the ide's seem to be frustrating and very difficult. I have used PHP ides and don't have any problems with that. I use notepad++ for php. Very easy.
Right now I am trying to get a grasp of java before I start classes in school. By the way the netbeans website does not allow for downloading Netbeans. I spent 15 minutes trying to download Netbeans. Never mind I found a link that works.
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler
Mark Roberge wrote:Hi
I am very new to Java. I am trying to find an ide to write java code without a lot of figuring out how to get the ide to work. I have tried IntelliJ. I got one program to work. I am reading Learning Java and java in a nutshell. When I tried to write a modified code I could not. I have also tried BlueJ. Couldn't even write code. I tried getting netbeans. Could not find a download. I went to netbeans site. Right now I am about to try greenfoot. I think there were a few others but I don't remember.
Mark
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
Don't get me started about those stupid light bulbs. |