Importing library in Java -


i new in java , learning book called "thinking in java". author wrote 1 library called net ease understanding. example, print in place of system.out.println , likewise. so, how can import library?

update:
author in example following:

import static net.mindview.util.range.*; import static net.mindview.util.print.*; 

and looked @ source codes , found build.xml in net folder

basically, compile project externally provided library, should add classpath. there multiple ways based on tools using. if go "rough" way using text editor , javac (recommended beginners), can this:

javac -classpath .:/path/to/the/folder/containing/your/library myclass.java 

in case if folder net in folder d:\libraries compilation command this:

javac -classpath .:d:\libraries myclass.java 

then in source code can import library way author does, i.e. copy past code:

import static net.mindview.util.range.*; import static net.mindview.util.print.*;  public class myclass { ..... } 

if use ide (for example netbeans) add library project. right-click on libraries in projects window , choose add jar/folder, navigate folder containing net library (folder d:\libraries in previous example). ide automatically add classpath during compilation.

p.s. if beginner in programming, recommend avoiding thinking in java - meant people wishing broaden knowledge @ post-beginner level. start java: how program deitel - written beginners , not use author-developed libraries confusing beginner , hiding important language details you.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -