Carey Brown wrote:This would be a better approach; creating static print() methods to do the work.
tony baloni wrote:Hello, I am a total newbie to start to learn Java,. So many tutorials start with IDE. In order to get a clear understanding of how java work, I don't want any distractions from IDEs, I just want to do it in a plain text editor.
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Harry Kar wrote:
tony baloni wrote:Hello, I am a total newbie to start to learn Java,. So many tutorials start with IDE. In order to get a clear understanding of how java work, I don't want any distractions from IDEs, I just want to do it in a plain text editor.
Your point about starters and heavy IDE's is absolutely righti can say i hear it only rarely trough starters.But you have to know other than heavy/professional IDE's(e.g. NetBeans, Eclipse, IntelliJ) out there exist also very simple "IDE's" specifically thought and implemented for students/starters(for teaching/learning) e.g. BlueJ and DrJava . They are written in java and offer only a bit more than a plain text editor so no distraction
Apart your specific question here are few pointers to help you go further:
1. It's recommended when one start to learn OO Programming other than start learn the language itself he/she choose, start learn also about OO Design. Really the later in my humble opinion is more important and applicable to any language.
2. take a look in that thread OOP, what is an Object? i guess you will find it useful
3. Take a look (often) in our small(in expansion) library of good open texts ; start look at the section Beginners books subsections OO related and Java; Everything you choose there it's good
If you have no idea where to start get a try for example at
Think Java How to Think Like a Computer Scientist 2002 by Allen B. Downey Introduction to Programming Using Java, Version 7.0, August 2014 by David J. Eck Object-Oriented Programming used Java 2006 by David J. Eck, et al Object-oriented Programming in JavaTM Textbook by Richard L. Halterman 2008(use DrJava) OOP - Learn Object Oriented Thinking & Programming 2013 by Rudolf Pecinovsky (use BlueJ)
Downey's small textbook is almost ideal for starters(is small and uses the necessary Java's subset for start and avoid student's overwhelming) i guess
The last (Pecinovsky) is made in a particular way (respectively of other traditional textbooks) trough dialogs between an hypothetical student/learner and his teacher
And ... Welcome to Ranch!![]()
tony baloni wrote:
Thanks for your input.
I remember in the old days when I started programming in then Obj-C for iOS. I started with XCode. It was quite a struggle joggling between XCode and Obj-C . Later on I realized that there were a lot of basics I don't understand., such the compile and linking process and program structure because XCode did all that for me. I am going to learn the "hard" way-with just a simple good old text editor and the Terminal, so that I have better understanding
As for as OOP concern, I think I have a pretty good grab on it, but I will read some of the books recommended.
Now as for the usage of javac -d, I still need some time to search for the answer.
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
tony baloni wrote: Thank you again for all you guys helps.
Now it start to make sense to my little brain So what are the pros and cons in using static and non-static? In what situation would I use one or the other? Does it have to do with code security?
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
tony baloni wrote:Now as for the usage of javac -d, I still need some time to search for the answer.
All things are lawful, but not all things are profitable.
Campbell Ritchie wrote:I believe the −d option to javac will create the required directory if it doesn't already exist. But I haven't used −d for ages.
-d directory
Sets the destination directory for class files. The directory must already exist because javac does not create it. If a class is part of a package, then javac puts the class file in a subdirectory that reflects the package name and creates directories as needed.
If you specify -d C:\myclasses and the class is called com.mypackage.MyClass, then the class file is C:\myclasses\com\mypackage\MyClass.class.
If the -d option is not specified, then javac puts each class file in the same directory as the source file from which it was generated.
Note: The directory specified by the -d option is not automatically added to your user class path.
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Carey Brown wrote:This would be a better approach; creating static print() methods to do the work.
tony baloni wrote:I followed Carey Brown' instruction I created two files HelloWorld.java and GoodbyWorld.java I put them in a folder called java_exercises than I cd to this directory, javac them. When I did javac HelloWorld.java it generate a HelloWorld.class as well as a GoodbyeWorld.class, But when I try to run it. java HelloWorld, the terminal give this error:
Error: Could not find or load main class .Users.tony.Desktop.java_exercises.HelloWorld
What have I done wrong?
Harry Kar wrote: (...) Your point about starters and heavy IDE's is absolutely right
There are three kinds of actuaries: those who can count, and those who can't.
I have just tried it with a non‑existent directory and a new directory was created. Maybe the behaviour is OS‑dependent, but I don't think so.Harry Kar wrote:. . . No the directory must already exist . . .
Carey Brown wrote:
tony baloni wrote:I followed Carey Brown' instruction I created two files HelloWorld.java and GoodbyWorld.java I put them in a folder called java_exercises than I cd to this directory, javac them. When I did javac HelloWorld.java it generate a HelloWorld.class as well as a GoodbyeWorld.class, But when I try to run it. java HelloWorld, the terminal give this error:
Error: Could not find or load main class .Users.tony.Desktop.java_exercises.HelloWorld
What have I done wrong?
Did you cd into the same directory to run the program?
You aren't declaring any 'package's in the .java files?
You could try adding in class path:
Carey Brown wrote:
True. Comment out line 3.
Piet Souris wrote:
Harry Kar wrote: (...) Your point about starters and heavy IDE's is absolutely right
Relatively right, since not all agree.
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Campbell Ritchie wrote:
I have just tried it with a non‑existent directory and a new directory was created. Maybe the behaviour is OS‑dependent, but I don't think so.Harry Kar wrote:. . . No the directory must already exist . . .
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]
Campbell Ritchie wrote:I think you have proven that we are in agreement. You are showing compilation with no source directory failing, and that isn't what I meant. I meant that the destination directory is created by the −d option.
vs your previous post..You are showing compilation with no source directory failing,..
Campbell Ritchie wrote:
Harry Kar wrote:
. . . No the directory must already exist . . .
I have just tried it with a non‑existent directory and a new directory was created.
[Arguing with an engineer is a lot like wrestling in the mud with a pig. After a few hours, you realize that he likes it] [Learn code first? no we apply to learn programming(or also)first thanks]