Tips and tricks for working with Java.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea
.gitignore
CharacterMathDemo.java
HashMapDemo.java
LICENSE
README.md
RunnableDemo.java
SplitDemo.java
java-tricks.iml

README.md

Java Tips and Tricks

You learn a lot of Java here at Lehigh, but when it comes down to it, you're just scratching the surface.

Java IDE's

IDE stands for Integrated Development Environment. It's basically an advanced code editor that provides extra features on top of editing text, like file management, automating builds, and testing. Dr. Java, the editor used in CSE 2, is not an IDE. Netbeans, often used in CSE 17, is. However, not many professionals use Netbeans. Instead, most of them use Eclipse and IntelliJ.

Eclipse

Free to use. You can just grab the standard version. Download

IntelliJ

There's a professional version you have to pay for, but they also have a free Community Edition that will satisfy all of your needs. This project includes IntelliJ project files to make getting started easy. Download

Compiling a Project from the Command Line

If you stick with Java, at some point in your life, you'll run into a situation where you can't have an IDE compile for you. For example, for small things, I personally don't like to use IDEs at all. I use my favorite text editor, Sublime Text, which doesn't compile Java out of the box. Thankfully, doing simple Java compilations are a piece of cake (although they can quickly get quite complex).

  1. Open your terminal of choice.
  2. Navigate to the folder of your .java file.
  3. To compile your program, first run the command javac YourFile.java. This will create the file YourFile.class. If there were any compilation errors, it'll tell you.
  4. To actually run your program, use the command java YourFile. Note that we didn't put any extension after YourFile. If YourFile.class exists, Java will automatically grab and run it.
  5. That's it! Pretty simple, right? You could write Java programs in Notepad this way (although I wouldn't recommend it...).