How To Install Java 7 On Windows 8
How to Install JDK 17 (on Windows, macOS & Ubuntu) and Get Started with Java Programming
The Java Evolution Kit (JDK), officially named "Java Platform Standard Edition" or "Java SE", is needed for writing and running Java programs.
JDK Variants
At that place are few variants of JDK:
- OpenJDK: Currently, the "OpenJDK" adult by Oracle and the Java community (@ https://openjdk.coffee.cyberspace/) provides a complimentary and open-source JDK official reference implementation.
- OracleJDK: This article is based on the "OracleJDK" (@ https://www.oracle.com/coffee/) (due to legacy), which is free for personal and development use merely no longer free for commercial use.
JDK Versions
Reference: "Java Version History" @ https://en.wikipedia.org/wiki/Java_version_history.
- JDK Alpha and Beta (1995): Lord's day Microsystem announced Java in September 23, 1995.
- JDK 1.0 (January 1996): Originally called Oak (named after the oak tree outside James Gosling's office). Renamed to Java ane in JDK 1.0.2.
- JDK 1.1 (February 1997): Introduced AWT event model, inner grade, JavaBean, JDBC, and RMI.
- J2SE i.ii (JDK 1.2) (December 1998): Re-branded as "Java ii" and renamed JDK to J2SE (Java two Standard Edition). Besides released J2EE (Coffee 2 Enterprise Edition) and J2ME (Java 2 Micro Edition). Included JFC (Coffee Foundation Classes - Swing, Accessibility API, Java second, Pluggable Await & Experience, and Drag & Drop). As well introduced Drove Framework and JIT compiler.
- J2SE 1.iii (JDK 1.3) (May 2000): Introduced Hotspot JVM.
- J2SE 1.four (JDK i.4) (February 2002): Introduced
assertstatement, not-blocking IO (nio), logging API, image IO, Java webstart, regular expression (regex) support. - J2SE 5.0 (JDK 5) (September 2004): Officially called five.0 instead of 1.5 (past dropping the 1.). Introduced generics, autoboxing/unboxing, annotation, enum, varargs, for-each loop, static import. See "JDK 5 New Features".
- Coffee SE 6 (JDK 6) (December 2006): Renamed J2SE to Java SE (Java Platform Standard Edition). No new language features. Run across "JDK 6 New Features".
- Java SE vii (JDK 7) (July 2022): Beginning version later Oracle purchased Sunday Microsystem - aslo chosen OracleJDK. Introduced Strings in
switchstatement, Binary integer literals, allowing underscores in numeric literals, improved type inference for generic instance creation (or diamond operator<>), Catching multiple exception types and rethrowing exceptions with improved type checking. Meet "JDK 7 New Features". - Java SE eight LTS (JDK eight) (March 2022): Included support for Lambda expressions, default and static methods in interfaces, improved collection, and JavaScript runtime. Also integrated JavaFX graphics subsystem. See "JDK viii New Features".
- Java SE nine (JDK nine) (September 21, 2022): Introduced modularization of the JDK (
module) nether project Jigsaw, the Java Shell (jshell), and more. See "JDK 9 New Features". - Java SE x (eighteen.3) (JDK 10) (March 2022): Introduced
varfor type inference local variable (similar to JavaScript). Introduced time-based release versioning with 2 releases each yr, in March and September, denoted asYY.M.Removed native-header generation tooljavah. See "JDK 10 New Features". - Java SE 11 LTS (18.9) (JDK 11) (September 2022): Extended
varto lambda expression. Standardize HTTP client incoffee.cyberspace.http. Support TLS one.3. Make clean up the JDK and the installation package (removed JavaFX, JavaEE, CORBA modules, deprecated Nashorn JavaScript engine). OracleJDK is no longer gratis for commercial use, but OpenJDK is however free. See "JDK eleven New Features". - Java SE 12 (nineteen.3) (JDK 12) (March 2022): Switch Expression (preview). See "JDK 12 New Features".
- Java SE thirteen (19.9) (JDK 13) (September 2022): Switch Expression (preview), Multi-line Text Block (preview). See "JDK 13 New Features".
- Java SE 14 (20.3) (JDK 14) (March 2022): Records (preview)
- Coffee SE 15 LTS (20.nine) (JDK 15) (September 2022):
- Java SE sixteen (JDK sixteen) (March 2022):
- Java SE 17 LTS (JDK 17) (September 2022):
- Java SE 18 (JDK eighteen) (March 2022):
"JDK" or "JRE"?
JRE (Java Runtime), which include a Java Virtual Automobile and core libraries, is needed for running Java programs. JDK (Java Development Kit), which includes JRE plus the evolution tools (such as compiler and debugger), is need for writing as well equally running Java programs. In other words, JRE is a subset of JDK. Since you are supposed to write Java Programs instead of simply running Coffee programs, you should install JDK, which includes JRE.
How To Install JDK on Windows
Stride 0: United nations-Install Older Version(due south) of JDK/JRE
I recommend that y'all install only the latest JDK. Although you lot tin can install multiple versions of JDK/JRE concurrently, it is messy.
If you have previously installed older version(s) of JDK/JRE, un-install ALL of them. Goto "Command Console" ⇒ (optional) "Programs" ⇒ "Programs and Features" ⇒ Un-install ALL programs begin with "Java", such as "Java SE Development Kit ...", "Java SE Runtime ...", "Java X Update ...", and etc.
Step 1: Download JDK
- Goto JDK (or Java SE) download site @ https://www.oracle.com/coffee/technologies/javase-downloads.html.
- Under "Java SE Development Kit 17.0.{x} downloads".
- Select "Windows" ⇒ Download the "x64 Installer" (e.grand., "
jdk-17_windows-x64_bin.exe" - virtually 152MB).
Step 2: Install JDK
Run the downloaded installer. Accept the defaults and follow the screen instructions to complete the installation. By default, JDK is installed in directory "C:\Program Files\Java\jdk-17.0.{x} ", where {x} denotes the running "update number" starting from 1.
Launch "File Explorer". Navigate to "C:\Program Files\Coffee" to inspect this directories. Have note of your JDK Installed Directory jdk-17.0.{x} , in detail, the update number {x} .
I shall refer to the JDK Installed Directory as <JAVA_HOME> , time to come, in this article (corresponding to environment variable %JAVA_HOME% in Windows or $JAVA_HOME in Unix/macOS).
Stride 3: (SKIP for JDK 17, 16, 16 - kept for completeness) Include JDK's "bin" Directory in the PATH
Windows' Control Prompt (CMD) searches the current directory and the directories listed in the PATH environment variable for executable programs.
JDK'due south programs (such as Java compiler "javac.exe" and Java runtime "java.exe") reside in the sub-directory "bin" of the JDK installed directory. JDK's "bin" needs to exist added into the PATH.
Prior to JDK xv, you need to explicitly add JDK'due south "bin" into the PATH. Starting from JDK 15, the installation process adds the directory "C:\Plan Files\Common Files\Oracle\Coffee\javapath" to the PATH. The "javapath" directory is a link to "javapath_target_xxxxxx", which contains a copy of the following JDK programs:
-
java.exe: Java Runtime -
javac.exe: Java Compiler -
javaw.exe: Java Runtime for Windows Console-less -
jshell.exe: Java Command-line Beat (since JDK ten) - a Read-Evaluate-Print Loop (REPL) which evaluates declarations, statements, and expressions as they are entered and immediately shows the results.
Link is used so that y'all can go along multiple copies (versions) of JDK.
To edit the PATH surroundings variable in Windows ten:
- Launch "Control Panel" ⇒ (Optional) "Arrangement and Security" ⇒ "System" ⇒ Click "Advanced system settings" on the left pane.
- Switch to "Advanced" tab ⇒ Click "Surround Variables" push.
- Under "Arrangement Variables" (the bottom pane), scroll down to select variable "Path" ⇒ Click "Edit...".
- For Newer Windows ten:
You shall encounter a Table listing all the existing PATH entries (if non, goto next step). Click "New" ⇒ Click "Scan" and navigate to your JDK's "bin" directory, i.e., "c:\Program Files\Java\jdk-fifteen.0.{x}\bin", where{x}is your installation update number ⇒ Select "Move Up" to move this entry all the way to the Tiptop. - For Older Windows 10 (Time to change your calculator!):
(Circumspection: Read this paragraph 3 times before doing this footstep! Don't push "Employ" or "OK" until you lot are 101% certain. At that place is no Disengage!!!)
(To be SAFE, copy the content of the "Variable value" to Notepad before irresolute it!!!)
In "Variable value" field, APPEND "c:\Program Files\Java\jdk-xv.0.{x}\bin" (where{x}is your installation update number) IN Front end of all the existing directories, followed by a semi-colon (;) to separate the JDK's bin directory from the rest of the existing directories. Do NOT DELETE any existing entries; otherwise, some existing applications may not run.Variable name : PATH Variable value : c:\Program Files\Java\jdk-15.0.{x}\bin; [do non delete exiting entries...]
You need to re-started CMD for the new surroundings settings to accept consequence.
Step 4: Verify the JDK Installation
Launch a CMD via one of the post-obit means:
- Click "Search" button ⇒ Type "cmd" ⇒ Choose "Control Prompt", or
- Right-click "Outset" push button ⇒ run... ⇒ enter "cmd", or
- Click "Start" button ⇒ Windows System ⇒ Command Prompt
Issue the following commands to verify your JDK installation:
- (Skip for JDK 17, 16, 15) Event "
path" control to list the contents of thePATHsurround variable. Check to brand sure that your JDK'south "bin" is listed in thePATH.path PATH=c:\Program Files\Java\jdk-{xx.y.z}\bin;other entries... - Issue the following commands to verify that JDK/JRE are properly installed and display their version:
javac -version javac 17.0.1 java -version coffee version "17.0.1" 2022-10-19 LTS Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39) Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)
Step 5: Write a Howdy-Globe Java Plan
- Create a directory to proceed your works, east.g., "
d:\myProject" or "c:\myProject". Exercise NOT save your works in "Desktop" or "Documents" as they are hard to locate. The directory proper noun shall not incorporate blank or special characters. Use meaningful merely short name as it is easier to blazon. - Launch a programming text editor (such every bit TextPad, NotePad++, Sublime Text, Atom). Begin with a new file and enter the following source lawmaking. Save the file equally "
Hi.java", under your work directory (east.g.,d:\myProject).public class Hullo { public static void principal(Cord[] args) { System.out.println("Hello, world!"); } }
Footstep 6: Compile and Run the Hullo-Earth Java Program
To compile the source lawmaking "Hello.java":
- Offset a CMD Beat (Search ⇒ enter "cmd" ⇒ select "Control Prompt").
- Set the Current Drive to the bulldoze where you saved your source file "
Hello.coffee".
If you use drive "c", skip this step.
Else if you utilise drive "d", enter "d:" every bit follow:d: D:\thirty> - Set the Current Working Directory to the directory that you saved your source file via the
cd(Alter Directory) control. For case, suppose that your source file is saved in directory "myProject".
cd \myProject D:\myProject> - Issue a
dir(Listing Directory) control to confirm that your source file is present in the current directory.dir ...... twenty-xxx-twenty xx:20 PM 277 Hello.java ...... - Invoke the JDK compiler "
javac" to compile the source code "Hello.java".javac Hi.coffee
The compilation is successful if the command prompt returns. Otherwise, error messages would be shown. Correct the errors in your source file and re-compile. Cheque "Common JDK Installation Errors", if you encounter problem compiling your program. - The output of the compilation is a Java class called "
Hello.grade". Issue adir(Listing Directory) command over again to check for the output.dir ...... xx-xxx-xx xx:xx PM 416 Hello.class twenty-30-xx twenty:xx PM 277 Hi.java ......
To run the program, invoke the Java Runtime " java ":
coffee Hullo Hello, world! Everything that can possibly go wrong will go wrong: Read "JDK Installation Common Errors".
Step 7: (For Avant-garde Users Only) JDK's Source Code
Source lawmaking for JDK is provided and kept in "<JAVA_HOME>\lib\src.zip" (or "<JAVA_HOME>\src.zip" prior to JDK ix). I strongly recommend that you to get through some of the source files such equally "String.coffee", "Math.java", and "Integer.java", under "java\lang", to learn how experts programme.
How to Install JDK on macOS
Step 1: Check if JDK has been Pre-Installed
To bank check if JDK has been installed, open a "Terminal" (Search "Final"; or Finder ⇒ Go ⇒ Utilities ⇒ Terminal) and consequence this control:
javac -version
- If a JDK version number is returned (due east.one thousand.,
JDK ten.x.x), then JDK has already been installed. If the JDK version is prior to 11, proceed to Step 2 to install the latest JDK; otherwise, proceed to "Step 3: Write a Howdy-earth Java program". - If message "control not found" appears, JDK is Non installed. Proceed to the "Footstep ii: Install JDK".
- If bulletin "To open javac, you need a Java runtime" appears, select "Install" and follow the instructions to install JDK. So, proceed to "Step 3: Write a Hello-world Java plan".
Step 2: Download JDK
- Goto JDK (or Java SE) download site @ https://www.oracle.com/coffee/technologies/javase-downloads.html.
- Under "Java SE Development Kit 17.0.{x} downloads".
- Select "macOS" ⇒ Download the "x64 Installer" (e.k., "
jdk-17_windows-x64_bin.exe" - about 152MB). - Under "Oracle JDK", click "JDK Download".
- Download the "x64 DMG installer" (east.g,
jdk-17_macos-x64_bin. dmg- well-nigh 168MB (I am bold that you are using Intel processor, not ARM processor. Mac is moving to ARM processor.)
Footstep three: Install JDK/JRE
- Double-click the downloaded Disk Epitome (DMG) file. Follow the screen instructions to install JDK/JRE.
- Squirt the DMG file.
- To verify your installation, open a "Terminal" and upshot these commands.
javac -version javac 17.0.{ten} coffee -version java version "17.0.{x}" ...... which javac /usr/bin/javac which coffee /usr/bin/java
Pace iii: Write a Howdy-World Java Plan
- Create a directory called "
myProject" under your "abode" directory (Launch "Finder" ⇒ "Go" ⇒ "Home"; Select "File" ⇒ "New Folder" ⇒ "myProject").
In macOS/Unix, the "habitation" directory of the current user can be referenced as "~". Hence, this new directory tin exist referenced every bit "~/myProject". - Use a programming text editor (such as Sublime Text or Cantlet) to input the following source code and relieve equally "
Hello.coffee" nether the directory "~/myProject".
(If you employ macOS's default text editor "TextEdit" (Not recommended), you demand to open a new file ⇒ choose "Format" ⇒ "Make Patently Text" ⇒ Enter the source code ⇒ Save as "Howdy.java".)public grade Hullo { public static void main(Cord[] args) { System.out.println("How-do-you-do, globe from Mac!"); } }
Stride 4: Compile and Run the Hi-Globe Java Plan
- To compile the source code "
Howdy.java", open a new "Final" ("Get" ⇒ "Utilities" ⇒ "Terminal") and issue these commands (as illustrated):cd ~/myProject ls Hullo.java ...... javac How-do-you-do.java ls Howdy.class Hullo.java ......
- To run the Howdy-world, invoke the Java Runtime "
coffee" as follows:java Hello Hello, world from Mac!
How to Install JDK (15) on Ubuntu
We shall endeavour both the OpenJDK (gratuitous and open-source) and the Oracle JDK (gratis for personal and development, simply not gratuitous for production).
Step 0: Check if JDK has already been Installed
Open up a Terminal and issue this command:
$ javac -version
If a JDK version number (eastward.g., "javac 10.x.x") appears, JDK has already been installed. You lot can skia the installation and goto Open2.
Step 1a: Install OpenJDK
[TODO]
To remove OpenJDK, effect command:
$ sudo apt-get purge openjdk-\*
Footstep 1b: Install Oracle JDK
- Goto Oracle JDK (Java SE) download site @ https://world wide web.oracle.com/java/technologies/javase-downloads.html ⇒ Under "Oracle JDK", click "JDK Download" ⇒ Select "Linux x64 Compressed Archive" parcel (e.one thousand., "
jdk-15.0.{x}-linux-x64_bin.tar.gz" - 179MB). The tarball will be downloaded in directory "~/Downloads", by default. - We shall install JDK nether "
/usr/local/coffee" (or Ubuntu'south default JDK directory/usr/lib/jvm; or/opt/java). Offset, create a directory "java" nether "/usr/local". Open a Last and issue these commands:$ cd /usr/local $ sudo mkdir coffee
Extract the downloaded parcel (Check your downloaded filename!)$ cd /usr/local/java $ sudo tar xzvf ~/Downloads/jdk-15.0.{x}-linux-x64_bin.tar.gzJDK shall be extracted in a folder "/usr/local/java/jdk-xv.0.{x}", where{x}is the update number. - Inform the Ubuntu to use this JDK/JRE:
$ sudo update-alternatives --install "/usr/bin/coffee" "coffee" "/usr/local/java/jdk-15.0.{ten}/bin/java" 1 $ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk-15.0.{ten}/bin/javac" i $ sudo update-alternatives --install "/usr/bin/jshell" "java/usr/local/java/jdk-15.0.{x}/bin/jshell" i $ sudo update-alternatives --set java /usr/local/java/jdk-fifteen.0.{10}/bin/java $ sudo update-alternatives --set up javac /usr/local/java/jdk-15.0.{10}/bin/javac $ sudo update-alternatives --set up jshell /usr/local/coffee/jdk-15.0.{x}/bin/jshellThe higher up steps gear up symlinksjava,javac,jshellat/usr/bin(which is in the PATH), that link to/etc/alternativesand so to JDK bin directory.
The "alternatives" system aims to resolve the state of affairs where several programs fulfilling the aforementioned part (e.g., different version of JDKs). It sets upwardly symlinks thru/etc/alternativesto refer to the actual programs to be used.
$ ls -ld /usr/bin/coffee* lrwxrwxrwx i root root 20 xxx twenty xx:20 /usr/bin/java -> /etc/alternatives/java ...... $ ls -ld /etc/alternatives/java* lrwxrwxrwx 1 root root xx xxx xx xx:xx /etc/alternatives/java -> /usr/local/java/jdk-15.0.{x}/bin/java ...... java -> /usr/bin/java (thru PATH) -> /etc/alternatives/java -> /usr/local/java/jdk-15.0.{ten}/bin/java (actual plan)
Alternatively, y'all can include the JDK's bin into the PATH directly. - To verify the JDK installation, issue these commands:
$ javac -version javac xv.0.{x} $ coffee -version java version "fifteen.0.{x}" ...... $ which javac /usr/bin/javac $ which java /usr/bin/java
- (Don't Do this step - It is taken care by "alternatives" in Pace 3. Go along here to testify you how to set PATH.)
Add JDK's binary directory ("bin") to the "PATH" by editing "/etc/profile":$ cd /etc $ sudo nano profile
Add these lines at the terminate of the file "/etc/profile", supersede "{x}" with the actual number:export JAVA_HOME=/usr/local/coffee/jdk-15.0.{x} export PATH=$JAVA_HOME/bin:$PATHRerun the configuration file by:$ source /etc/contour $ echo $JAVA_HOME /usr/local/java/jdk-15.0.{x} $ echo $PATH /usr/local/java/jdk-15.0.{ten}/bin:......
Step two: Compile and Run a Hello-world Java Program
- File Explorer ⇒ Home ⇒ Create a new folder called "
myProject" to continue our works. - Open up "Text Editor" (gedit). Enter the following source code and save as "
Hullo.java" nether the "~/myProject" directory created earlier.public class Hello { public static void main(Cord[] args) { System.out.println("Hello, earth from Ubuntu!"); } } - To compile the Hullo-world Java program, launch a Terminal and issue these commands:
$ cd ~/myProject $ ls ...... Hello.coffee ...... $ javac Hello.java $ ls ...... Howdy.class ......
- Run the How-do-you-do-world Coffee programme:
$ java Hi Hello, world from Ubuntu!
Notes: Starting from JDK 11, you can compile and run the hello-globe in one single stride via:
$ java Hello.java Hello, world from Ubuntu! Source-Lawmaking Editors & IDEs for Java Programming
Eclipse IDE
- You need to first install Eclipse. Read "How to Install Eclipse".
- javaan then keep to write your kickoff Java program. Read "Writing your commencement Java Program with Eclipse".
- Eclipse permit you to debug program graphically. Read "Debugging program in Eclipse".
NetBeans IDE
- Yous need to first install NetBeans. Read "How to Install NetBeans".
- You can then proceed to write your outset Java plan. Read "Writing your first Java program with NetBeans".
- NetBeans permit you lot to debug plan graphically. Read "Debugging program in NetBeans".
Visual Studio (VS) Lawmaking IDE
Click HERE, look for "VS Lawmaking for Coffee Programming"
Sublime Text (for Windows, macOS, Linux)
Click Here, await for "Sublime Text for Java Programming"
Cantlet (for Windows, macOS, Linux)
[TODO]
TextPad (for Windows only)
Click HERE, look for "TextPad for Java Programming".
NotePad++ (for Windows simply)
Click Hither, look for "NotePad++ for Coffee Programming".
(JDK xi New Feature) Launch Single-Source-File
From JDK 11, you tin "compile and run" a single-file program in one footstep, without explicit compilation.
- Write a "
Hello.java" (see previous section). - Delete "
Howdy.class", if it exists. - You tin compile/run "
Hello.java" in ane control equally follows:java Hello.java Hello, earth!
Notes:
- This is applicable to single source-file only.
- No need to use
javacto compile the plan. - It compiles in retentivity (without producing a
.classfile), and run. - This characteristic is introduced for beginners to acquire Java, and for professionals to test a Java feature.
- The filename and classname need not be the same.
How To Set JAVA_HOME Environment Variable
Many Coffee applications (such as Tomcat) require the environment variable JAVA_HOME to be set to the JDK installed directory.
See "How to gear up JAVA_HOME for Windows" or "How to set JAVA_HOME for macOS/Linux".
Common Errors in installing JDK
SYMPTOM: Cannot compile Java program from the CMD shell (e.m., "javac Hello.java" does non work!) Fault Bulletin: 'javac' is not recognized as an internal or external command, operable program or batch file. PROBABLE CAUSES: The PATH environs variable, which maintains a list of search paths for executable programs (including "javac.exe"), does not include JDK's bin directory. POSSIBLE SOLUTIONS: 1) Start a CMD vanquish (click "First" button ⇒ "run..." ⇒ enter "cmd") and issue a path control: prompt> path PATH=....... 2) Check if it includes your JDK's "bin" directory. For example, suppose that your JDK is installed in "c:\plan files\java\jdk-15.0.1", then PATH should include "c:\program files\coffee\jdk-15.0.1\bin". Otherwise, include JDK'southward bin directory in the PATH environment variable. Read "Step three of How to install JDK".
SYMPTOM: Can compile only cannot run Java program from the CMD shell (e.k., "java Hello" does not work!) ERROR MESSAGE (Mail JDK 1.7): Mistake: Could not notice or load main grade Xxx Fault Message (Pre JDK one.vii): Exception in thread "main" java.lang.NoClassDefFoundError: Xxx PROBABLE CAUSES: i) The Java class (in this example, How-do-you-do.class) is NOT in the current directory. 2) The CLASSPATH environs variable is set up, but does not include the current directory ".". POSSIBLE SOLUTIONS: 1) Issue a "dir" control to list the contents of the electric current directory. Bank check that information technology contains the Java form to be run (east.k., Hello.class). You demand to compile the source program (".coffee") to get the class file (".class"). 2) If the Coffee grade is present in the current directory, issue a "set classpath" command to bank check its settings: prompt> set classpath CLASSPATH=....... If yous receive the message "Environment variable CLASSPATH not defined" and your program is correct, I tin't help y'all here. Otherwise, if the CLASSPATH is defined, for beginner, I suggest that you remove the CLASSPATH environment variable. From "Control Console" ⇒ Organisation ⇒ (Vista only) Advanced system settings ⇒ Switch to "Avant-garde" tab ⇒ Environment Variables ⇒ System variables (and too User variables) ⇒ Select variable "CLASSPATH" ⇒ Delete (Delete from both the System variables and User variables) 3) (For Advanced Users Only) If CLASSPATH is not fix, it is defaulted to the electric current directory. Nonetheless, if CLASSPATH is set, the electric current directory is NOT implicitly included. You can include the current directory (denoted by a single dot ".") in front of the existing class-paths. Read "Coffee Applications and Environment Variable" for more give-and-take on CLASSPATH.
SYMPTOM: Can compile merely cannot run the Howdy-world program (due east.g., "java Hello" does non work!) Error MESSAGE (Mail JDK 1.7): Error: Main method not constitute in class Hello. POSSIBLE SOLUTIONS: Check whether there is a master() method in your program, and the signature of your master() equally shown in the error message. (Advanced) External JAR Files and Native Libraries
Notes: This section is applicable to JDK prior to JDK 9. JDK nine introduces a new level chosen "module" on pinnacle of package, and "jmod" files for Java modules. Need to revise this section for JDK ix.
External Java API packages (such as Servlet API, MySQL Connector/J, JOGL, JUnit) are often distributed in JAR files (Java Archive - a unmarried-file package of many Java classes similar to Zippo or TAR), with possibly Native Libraries (".lib" and ".dll" in Windows, or ".a" and ".so" in Linux/macOS).
External JAR Files (".jar")
If external JAR files are non properly included:
- During the compilation, y'all volition receive compilation mistake "cannot find symbol" for classes belonging to the external packages.
- During execution, you will get a runtime mistake "Could non detect or load chief grade xxx" or "
NoClassDefFoundError".
To include external JAR files, you can either:
- (Prior to JDK 9) Copy all the JAR files of the external packages to the Java's Extension Directories (Not applicable from JDK 9).
- For Windows, the JDK extension directory is located at "
<JAVA_HOME>\jre\lib\ext" (eastward.g., "c:\Program Files\Java\jdk1.eight.0_xx\jre\lib\ext"). - For macOS, the JDK extension directories are "
/Library/Java/Extensions" and "/System/Library/Java/Extensions". - For Ubuntu, the JDK extension directories are "
<JAVA_HOME>/jre/lib/ext" (e.thousand., "/usr/user/java/jdk1.8.0_xx/jre/lib/ext") and "/usr/java/packages/lib/ext".
coffee.ext.dirs". You can print its contents viaSystem.out.println(Organisation.getProperty("java.ext.dirs")). - For Windows, the JDK extension directory is located at "
- You tin also include all the JAR files in the
CLASSPATHenvironment variable.CLASSPATHmay incorporate directories (of Java classes) or JAR files (single-file archive of Java classes). If you set theCLASSPATH, you must likewise include the current directory (denoted as ".").- For Windows, ready the
CLASSPATHin Control Panel ⇒ System ⇒ Advanced system settings ⇒ Advanced ⇒ Surround Variables ⇒ System Variables ⇒ New ⇒ In "Variable name", enter "CLASSPATH" ⇒ In "Variable value", enter ".;path1\30.jar;path2\yyy.jar", where the entries are separated past a semi-colon (;). - For Linux and macOS: Edit
~/.profileor~/.bash_profile(or/etc/profilefor arrangement-wide setting) to include the following line at the end of the file:export CLASSPATH=.:path1/xxx.jar:path2/yyy.jar
The entries are separated by colon (:).
- For Windows, ready the
- You can also set the
CLASSPATHin thejavac/javacommand-line via the selection-cp <paths>(or-classpath <paths>), for example,javac -cp .;path1\xxx.jar;path2\yyy.jar ClassName.java coffee -cp .;path1\xxx.jar;path2\yyy.jar ClassName javac -cp .:path1/xxx.jar:path2/yyy.jar ClassName.java java -cp .:path1/xxx.jar:path2/yyy.jar ClassName
External Native Libraries (".lib", ".dll", ".a", ".so")
Some external package may provide static or shared native libraries in the class of ".lib" (Windows' static LIBrary), ".dll" (Windows' Dynamically Link Library), ".a" (Unix'southward static (Archive) library), or ".so" (Unix'south Shared Object library).
Native Libraries are to exist kept in a directory accessible via JRE's Property "java.library.path", which normally but not necessarily includes all the directories in the PATH environment variable.
Native libraries are non involved in the compilation. But if they are non properly included during runtime time, you will go a runtime mistake "java.lang.UnsatisfiedLinkError: no thirty in coffee.library.path".
To include external native libraries:
- Copy the native libraries into a system library directory, eastward.k.,
c:\windows\system32(Windows),/usr/libor/usr/local/lib(macOS/Unix). Yous can verify that the directory is included in Java's Arrangement Belongings "java.library.path", viaSystem.out.println(System.getProperty("coffee.library.path")). - You lot can also set the native library path via the
java's control-line option-Djava.library.path=thirty, for case,java -Djava.library.path=xxx ClassName
Eclipse/NetBeans
Using an IDE can greatly simplifies inclusion of external packages. Read "Eclipse How-To" or "NetBeans How-To".
Link to References & Resources
Source: https://www3.ntu.edu.sg/home/ehchua/programming/howto/JDK_Howto.html
Posted by: gunterthersemeaten.blogspot.com

0 Response to "How To Install Java 7 On Windows 8"
Post a Comment