{"id":28525,"date":"2021-07-28T09:45:33","date_gmt":"2021-07-28T02:45:33","guid":{"rendered":"https:\/\/wiki.tino.org\/staging\/?p=28525"},"modified":"2021-07-29T19:06:30","modified_gmt":"2021-07-29T12:06:30","slug":"sua-loi-error-could-not-find-or-load-main-class","status":"publish","type":"post","link":"https:\/\/tino.vn\/blog\/sua-loi-error-could-not-find-or-load-main-class\/","title":{"rendered":"S\u1eeda l\u1ed7i &#8220;Error: Could not find or load main class&#8221; hi\u1ec7u qu\u1ea3 100%"},"content":{"rendered":"\n<p><strong>Trong khi s\u1eed d\u1ee5ng ng\u00f4n ng\u1eef Java \u0111\u1ec3 l\u1eadp tr\u00ecnh, kh\u00f4ng \u00edt nh\u1eefng ng\u01b0\u1eddi g\u1eb7p ph\u1ea3i l\u1ed7i &#8220;Error: Could not find or load main class&#8221;, \u0111\u1eb7c bi\u1ec7t l\u00e0 nh\u1eefng ng\u01b0\u1eddi m\u1edbi. Trong b\u00e0i vi\u1ebft n\u00e0y, TinoHost s\u1ebd gi\u00fap b\u1ea1n t\u00ecm hi\u1ec3u nguy\u00ean nh\u00e2n v\u00e0 \u0111\u01b0a ra gi\u1ea3i ph\u00e1p gi\u00fap b\u1ea1n \u0111\u1ec3 s\u1eeda l\u1ed7i &#8220;Error: Could not find or load main class&#8221; th\u00e0nh c\u00f4ng nh\u00e9!<\/strong><\/p>\n\n\n\n<h2 id=\"V\u00ec_sao_l\u1ed7i_&#8220;Error:_Could_not_find_or_load_main_class&#8221;_xu\u1ea5t_hi\u1ec7n?\"><a id=\"post-28525-_36lkppu6juo\"><\/a><strong>V\u00ec sao l\u1ed7i &#8220;Error: Could not find or load main class&#8221; xu\u1ea5t hi\u1ec7n?<\/strong><\/h2>\n\n\n\n<h3 id=\"Nh\u1eefng_l\u00fd_do_ch\u00ednh_g\u00e2y_ra_l\u1ed7i_&#8220;Error:_Could_not_find_or_load_main_class&#8220;\"><a id=\"post-28525-_lz56d2gavuo9\"><\/a><strong>Nh\u1eefng l\u00fd do ch\u00ednh g\u00e2y ra l\u1ed7i &#8220;Error: Could not find or load main class<\/strong>&#8220;<\/h3>\n\n\n\n<p>3 l\u00fd do ch\u00ednh khi\u1ebfn ch\u01b0\u01a1ng tr\u00ecnh Java c\u1ee7a b\u1ea1n khi ch\u1ea1y v\u00e0 g\u1eb7p ph\u1ea3i l\u1ed7i &#8220;Error: Could not find or load main class&#8221; bao g\u1ed3m:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\u0110\u1eb7t t\u00ean sai v\u00e0 g\u1ecdi sai t\u00ean<\/strong><\/li><li><strong>Package b\u1ecb sai<\/strong><\/li><li><strong>Classpath kh\u00f4ng ch\u00ednh x\u00e1c\/ \u0111\u01b0\u1eddng d\u1eabn kh\u00f4ng ch\u00ednh x\u00e1c<\/strong><\/li><\/ul>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/07\/word-image-1408.png\" alt=\"sua-loi-error-could-not-find-or-load-main-class\" class=\"wp-image-28554\" width=\"704\" height=\"469\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/07\/word-image-1408.png 600w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/07\/word-image-1408-300x200.png 300w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><\/figure><\/div>\n\n\n\n<h3 id=\"V\u00ed_d\u1ee5_b\u1eb1ng_ch\u01b0\u01a1ng_tr\u00ecnh_c\u01a1_b\u1ea3n\"><a id=\"post-28525-_fjurbd2nfe98\"><\/a><strong>V\u00ed d\u1ee5 b\u1eb1ng ch\u01b0\u01a1ng tr\u00ecnh c\u01a1 b\u1ea3n<\/strong><\/h3>\n\n\n\n<p>Ph\u1ea7n l\u1edbn nh\u1eefng b\u1ea1n t\u00ecm \u0111\u1ebfn b\u00e0i vi\u1ebft n\u00e0y \u0111\u1ec1u ch\u1ee7 y\u1ebfu l\u00e0 ng\u01b0\u1eddi m\u1edbi h\u1ecdc Java, v\u00ec th\u1ebf, TinoHost s\u1ebd gi\u1ea3i th\u00edch th\u1eadt k\u1ef9 gi\u00fap b\u1ea1n v\u00e0 \u0111\u01b0a ra v\u00ed d\u1ee5 HelloWorld \u201cth\u1ea7n th\u00e1nh\u201d d\u1ec5 hi\u1ec3u nh\u01b0 sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class HelloWorld {\n\n public static void main(String&#91;] args) {\n\n System.out.println(\"Hello world!\");\n\n }\n\n}<\/code><\/pre>\n\n\n\n<p>Sau khi bi\u00ean d\u1ecbch, ch\u00fang ta s\u1ebd \u0111\u01b0\u1ee3c k\u1ebft qu\u1ea3 nh\u01b0 sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ javac HelloWorld.java. <\/code><\/pre>\n\n\n\n<p>\u0110\u1ed3ng ngh\u0129a v\u1edbi vi\u1ec7c ch\u00fang ta \u0111\u00e3 c\u00f3 \u0111\u01b0\u1ee3c m\u1ed9t t\u1ec7p th\u1ef1c thi .class \u0111\u01b0\u1ee3c sinh ra c\u00f3 c\u00f9ng t\u00ean v\u1edbi t\u00ean class trong ch\u01b0\u01a1ng tr\u00ecnh Java ph\u00eda tr\u00ean (public class HelloWorld).<\/p>\n\n\n\n<p>Thay v\u00ec l\u00e0m 2 ph\u1ea7n t\u00e1ch bi\u1ec7t bao g\u1ed3m l\u1ed7i v\u00e0 c\u00e1ch s\u1eeda l\u1ed7i, TinoHost s\u1ebd gom l\u1ea1i th\u00e0nh 1 ph\u1ea7n duy nh\u1ea5t: l\u1ed7i v\u00e0 c\u00e1ch s\u1eeda l\u1ed7i ngay trong c\u00f9ng 1 m\u1ee5c \u0111\u1ec3 b\u1ea1n d\u1ec5 theo d\u00f5i h\u01a1n nh\u00e9!<\/p>\n\n\n\n<p>M\u1ed9t s\u1ed1 t\u1eeb kh\u00f3a TinoHost s\u1ebd gi\u1eef nguy\u00ean trong b\u00e0i vi\u1ebft:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Class<\/strong>: l\u1edbp<\/li><li><strong>Package<\/strong>: g\u00f3i<\/li><\/ul>\n\n\n\n<h2 id=\"C\u00e1ch_s\u1eeda_l\u1ed7i_&#8220;Error:_Could_not_find_or_load_main_class&#8220;\"><a id=\"post-28525-_3f43pu8gbsmh\"><\/a><strong>C\u00e1ch s\u1eeda l\u1ed7i &#8220;Error: Could not find or load main class<\/strong>&#8220;<\/h2>\n\n\n\n<h3 id=\"L\u1ed7i_&#8220;Error:_Could_not_find_or_load_main_class&#8221;_do_\u0111\u1eb7t_t\u00ean_sai_v\u00e0_g\u1ecdi_sai_t\u00ean\"><a id=\"post-28525-_zbhfzxe3e9wk\"><\/a><strong>L\u1ed7i &#8220;Error: Could not find or load main class&#8221; do \u0111\u1eb7t t\u00ean sai v\u00e0 g\u1ecdi sai t\u00ean<\/strong><\/h3>\n\n\n\n<h4 id=\"V\u00ed_d\u1ee5_v\u1ec1_l\u1ed7i_\u0111\u1eb7t_sai_t\u00ean_v\u00e0_g\u1ecdi_sai_t\u00ean\"><a id=\"post-28525-_ka0grmts6gp7\"><\/a><strong>V\u00ed d\u1ee5 v\u1ec1 l\u1ed7i \u0111\u1eb7t sai t\u00ean v\u00e0 g\u1ecdi sai t\u00ean<\/strong><\/h4>\n\n\n\n<p>\u0110\u00e2y l\u00e0 m\u1ed9t l\u1ed7i ph\u1ed5 bi\u1ebfn r\u1ea5t nhi\u1ec1u ng\u01b0\u1eddi g\u1eb7p ph\u1ea3i v\u00ec ng\u00f4n ng\u1eef Java ph\u00e2n bi\u1ec7t ch\u1eef in hoa v\u00e0 ch\u1eef in th\u01b0\u1eddng. V\u00ed d\u1ee5 nh\u01b0 sau:<\/p>\n\n\n\n<p>Sau khi b\u1ea1n \u0111\u00e3 c\u00f3 \u0111\u01b0\u1ee3c file .class, ch\u00fang ta s\u1ebd ch\u1ea1y ch\u01b0\u01a1ng tr\u00ecnh b\u1eb1ng l\u1ec7nh sau:<\/p>\n\n\n\n<p><strong>java &lt;.class t\u00ean file&gt;<\/strong><\/p>\n\n\n\n<p>\u00c1p d\u1ee5ng v\u00e0o ch\u01b0\u01a1ng tr\u00ecnh m\u1eabu \u1edf tr\u00ean ch\u00fang ta s\u1ebd c\u00f3 nh\u01b0 sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ java helloworld\n\nError: Could not find or load main class helloworld<\/code><\/pre>\n\n\n\n<p>Nh\u01b0 b\u1ea1n th\u1ea5y, d\u00f2ng l\u1ed7i <strong>&#8220;Error: Could not find or load main class helloworld<\/strong>&#8221; hi\u1ec7n l\u00ean v\u00ec l\u00fd do:<\/p>\n\n\n\n<p>T\u1ec7p .class c\u00f3 t\u00ean l\u00e0 <strong>HelloWorld <\/strong>ch\u1ee9 kh\u00f4ng ph\u1ea3i <strong>helloworld. <\/strong>\u0110\u1ed3ng ngh\u0129a v\u1edbi vi\u1ec7c b\u1ea1n s\u1ebd ph\u1ea3i g\u00f5 ch\u00ednh x\u00e1c \u201c<strong>H<\/strong>ello<strong>W<\/strong>orld\u201d ch\u01b0\u01a1ng tr\u00ecnh c\u1ee7a b\u1ea1n m\u1edbi c\u00f3 th\u1ec3 ch\u1ea1y \u0111\u01b0\u1ee3c.<\/p>\n\n\n\n<p>T\u01b0\u01a1ng t\u1ef1, thay v\u00ec g\u1ecdi HelloWorld v\u00e0 b\u1ea1n g\u1ecdi <strong>HeloWorld <\/strong>(thi\u1ebfu l) hay <strong>HelloWord <\/strong>(thi\u1ebfu l) ch\u01b0\u01a1ng tr\u00ecnh c\u0169ng s\u1ebd b\u1ecb l\u1ed7i.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/07\/word-image-1409.png\" alt=\"sua-loi-error-could-not-find-or-load-main-class\" class=\"wp-image-28555\" width=\"692\" height=\"692\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/07\/word-image-1409.png 500w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/07\/word-image-1409-300x300.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/07\/word-image-1409-150x150.png 150w\" sizes=\"(max-width: 692px) 100vw, 692px\" \/><\/figure><\/div>\n\n\n\n<p>\u0110\u00f4i khi b\u1ea1n s\u1ebd d\u00f9ng l\u1ec7nh nh\u01b0 sau \u0111\u1ec3 ch\u1ea1y:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ java HelloWorld.class\n\nError: Could not find or load main class HelloWorld.class<\/code><\/pre>\n\n\n\n<p>\u0110\u1ed3ng ngh\u0129a v\u1edbi vi\u1ec7c b\u1ea1n g\u1ecdi lu\u00f4n c\u1ea3 ph\u1ea7n m\u1edf r\u1ed9ng .class c\u1ee7a HelloWorld. Tuy nhi\u00ean, \u0111i\u1ec1u n\u00e0y ho\u00e0n to\u00e0n kh\u00f4ng c\u1ea7n thi\u1ebft v\u00e0 g\u00e2y ra l\u1ed7i &#8220;Error: Could not find or load main class.&#8221;<\/p>\n\n\n\n<h4 id=\"S\u1eeda_l\u1ed7i_&#8220;Error:_Could_not_find_or_load_main_class&#8221;_do_\u0111\u1eb7t_sai_t\u00ean_v\u00e0_g\u1ecdi_sai_t\u00ean\"><a id=\"post-28525-_b51mrqdc84qo\"><\/a><strong>S\u1eeda l\u1ed7i &#8220;Error: Could not find or load main class&#8221; do \u0111\u1eb7t sai t\u00ean v\u00e0 g\u1ecdi sai t\u00ean<\/strong><\/h4>\n\n\n\n<p>Suy ra, c\u00e1ch \u0111\u1ec3 s\u1eeda l\u1ed7i n\u00e0y r\u1ea5t \u0111\u01a1n gi\u1ea3n. B\u1ea1n ch\u1ec9 c\u1ea7n <strong>ki\u1ec3m tra ch\u00ednh x\u00e1c t\u00ean g\u1ecdi <\/strong>c\u1ee7a .class b\u1ea1n \u0111\u00e3 t\u1ea1o \u1edf tr\u00ean. V\u00e0 tr\u00ecnh bi\u00ean d\u1ecbch c\u0169ng t\u1ef1 \u0111\u1ed9ng t\u1ea1o .class c\u00f3 c\u00f9ng t\u00ean v\u1edbi t\u00ean class b\u1ea1n \u0111\u1eb7t trong ch\u01b0\u01a1ng tr\u00ecnh.<\/p>\n\n\n\n<p>B\u1ea1n th\u1eed l\u1ea1i v\u1edbi \u0111\u00fang c\u00e1ch vi\u1ebft hoa, \u0111\u00fang ch\u00ednh t\u1ea3 v\u00e0 kh\u00f4ng th\u00eam ph\u1ea7n \u0111u\u00f4i m\u1edf r\u1ed9ng. Ch\u01b0\u01a1ng tr\u00ecnh c\u1ee7a b\u1ea1n s\u1ebd kh\u00f4ng b\u00e1o l\u1ed7i n\u1eefa:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ java HelloWorld\n\nHello world!<\/code><\/pre>\n\n\n\n<h3 id=\"L\u1ed7i_&#8220;Error:_Could_not_find_or_load_main_class&#8221;_do_Package_b\u1ecb_sai\"><a id=\"post-28525-_d4e8xhjvcjw3\"><\/a><strong>L\u1ed7i &#8220;Error: Could not find or load main class&#8221; do Package b\u1ecb sai<\/strong><\/h3>\n\n\n\n<h4 id=\"V\u00ed_d\u1ee5_v\u1ec1_l\u1ed7i_Package_b\u1ecb_sai\"><a id=\"post-28525-_vsq76gkfbi\"><\/a><strong>V\u00ed d\u1ee5 v\u1ec1 l\u1ed7i Package b\u1ecb sai<\/strong><\/h4>\n\n\n\n<p>Khi s\u1eed d\u1ee5ng Java, b\u1ea1n c\u00f3 th\u1ec3 t\u1ea1o ra c\u00e1c class t\u01b0\u01a1ng t\u1ef1 nhau v\u00e0 g\u00f3i g\u1ecdn l\u1ea1i trong m\u1ed9t package. V\u00e0 ch\u00fang ta s\u1ebd chuy\u1ec3n class HelloWorld v\u00e0o b\u00ean trong g\u00f3i com.tino nh\u01b0 sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package com.tino:\n\npublic class HelloWorld {\n\n public static void main(String&#91;] args) {\n\n System.out.println(\"Hello world!\");\n\n }\n\n}<\/code><\/pre>\n\n\n\n<p>B\u00e2y gi\u1edd b\u1ea1n ch\u1ec9 c\u1ea7n bi\u00ean d\u1ecbch sau \u0111\u00f3 ch\u1ea1y ch\u01b0\u01a1ng tr\u00ecnh HelloWorld v\u00e0 ch\u00fang ta s\u1ebd \u0111\u01b0\u1ee3c k\u1ebft qu\u1ea3 nh\u01b0 sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ java HelloWorld\nError: Could not find or load main class HelloWorld<\/code><\/pre>\n\n\n\n<h4 id=\"S\u1eeda_l\u1ed7i_&#8220;Error:_Could_not_find_or_load_main_class&#8221;_do_Package_b\u1ecb_sai\"><a id=\"post-28525-_l74zx413fui4\"><\/a><strong>S\u1eeda l\u1ed7i &#8220;Error: Could not find or load main class&#8221; do Package b\u1ecb sai<\/strong><\/h4>\n\n\n\n<p>Qu\u00e1 tr\u00ecnh nh\u1eadp c\u1ee7a b\u1ea1n kh\u00f4ng sai, vi\u1ebft \u0111\u00fang ch\u00ednh t\u1ea3 in hoa nh\u01b0ng l\u1ea1i kh\u00f4ng th\u1ec3 ch\u1ea1y \u0111\u01b0\u1ee3c l\u00e0 v\u00ec sao?<\/p>\n\n\n\n<p>L\u00fd do: <strong>Khi b\u1ea1n \u0111\u01b0a class v\u00e0o trong package, b\u1ea1n s\u1ebd c\u1ea7n ph\u1ea3i g\u1ecdi \u0111\u1ea7y \u0111\u1ee7 t\u00ean c\u1ee7a ch\u00fang.<\/strong> V\u00ec v\u1eady, trong tr\u01b0\u1eddng h\u1ee3p n\u00e0y, b\u1ea1n s\u1ebd c\u1ea7n g\u1ecdi \u0111\u1ea7y \u0111\u1ee7 package n\u00e0y l\u00e0: <strong>com.tino.HelloWorld<\/strong>.<\/p>\n\n\n\n<p>V\u1edbi c\u00e1ch t\u1ea1o n\u00e0y, b\u1ea1n s\u1ebd t\u1ea1o ra m\u1ed9t th\u01b0 m\u1ee5c c\u00e2y nh\u01b0 sau: com\/tino\/HelloWorld.java<\/p>\n\n\n\n<p>B\u1ea1n ch\u1ec9 c\u1ea7n \u0111\u1ea3m b\u1ea3o c\u00e1c t\u1ec7p trong th\u01b0 m\u1ee5c c\u00e2y n\u00e0y t\u1ed3n t\u1ea1i b\u1ea1n s\u1ebd c\u00f3 th\u1ec3 ch\u1ea1y \u0111\u01b0\u1ee3c ch\u01b0\u01a1ng tr\u00ecnh.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ java com.tino.HelloWorld\nHello world!<\/code><\/pre>\n\n\n\n<h3 id=\"Classpath_kh\u00f4ng_ch\u00ednh_x\u00e1c\/_\u0111\u01b0\u1eddng_d\u1eabn_kh\u00f4ng_ch\u00ednh_x\u00e1c\"><a id=\"post-28525-_g1cykdjna7ph\"><\/a><strong>Classpath kh\u00f4ng ch\u00ednh x\u00e1c\/ \u0111\u01b0\u1eddng d\u1eabn kh\u00f4ng ch\u00ednh x\u00e1c<\/strong><\/h3>\n\n\n\n<h4 id=\"Classpath_l\u00e0_g\u00ec?\"><a id=\"post-28525-_eblpkkct5b8e\"><\/a><strong>Classpath l\u00e0 g\u00ec?<\/strong><\/h4>\n\n\n\n<p>Classpath l\u00e0 m\u1ed9t tham s\u1ed1 trong JVM &#8211; java Virtual Machine (t\u1ea1m d\u1ecbch M\u00e1y \u1ea3o Java) ho\u1eb7c tr\u00ecnh bi\u00ean d\u1ecbch Java nh\u1eb1m \u0111\u1ec3 ch\u1ec9 v\u1ecb tr\u00ed c\u1ee7a c\u00e1c class v\u00e0 c\u00e1c package do ng\u01b0\u1eddi d\u00f9ng th\u1ef1c hi\u1ec7n.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2021\/07\/word-image-1410.png\" alt=\"sua-loi-error-could-not-find-or-load-main-class\" class=\"wp-image-28556\" width=\"613\" height=\"452\" title=\"\"><\/figure><\/div>\n\n\n\n<p>Gi\u1ea3i th\u00edch \u0111\u01a1n gi\u1ea3n h\u01a1n, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng Classpath \u0111\u1ec3 \u201cn\u00f3i\u201d v\u00e0 h\u01b0\u1edbng d\u1eabn cho JVM, tr\u00ecnh bi\u00ean d\u1ecbch Java bi\u1ebft t\u1ec7p .class \u0111ang \u1edf \u0111\u00e2u trong m\u00e1y t\u00ednh c\u1ee7a b\u1ea1n.<\/p>\n\n\n\n<p>B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng l\u1ec7nh sau:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java -classpath \/myprograms\/compiled HelloWorld<\/code><\/pre>\n\n\n\n<p>V\u00e0 Java s\u1ebd t\u1ef1 \u0111\u1ed9ng ch\u1ea1y \u0111i t\u00ecm theo \u0111\u01b0\u1eddng d\u1eabn \u0111\u1ec3 \u0111\u1ebfn class <strong>HelloWorld.<\/strong><\/p>\n\n\n\n<h4 id=\"S\u1eeda_l\u1ed7i_&#8220;Error:_Could_not_find_or_load_main_class&#8221;_do_Classpath_kh\u00f4ng_ch\u00ednh_x\u00e1c\"><a id=\"post-28525-_r04nbz94v7x5\"><\/a><strong>S\u1eeda l\u1ed7i &#8220;Error: Could not find or load main class&#8221; do Classpath kh\u00f4ng ch\u00ednh x\u00e1c<\/strong><\/h4>\n\n\n\n<p>C\u00e1ch s\u1eeda l\u1ed7i c\u0169ng kh\u00e1 \u0111\u01a1n gi\u1ea3n nh\u01b0 \u1edf ph\u1ea7n \u201cS\u1eeda l\u1ed7i Error: Could not find or load main class do \u0111\u1eb7t sai t\u00ean v\u00e0 g\u1ecdi sai t\u00ean\u201d. B\u1ea1n ch\u1ec9 c\u1ea7n ki\u1ec3m tra l\u1ea1i ch\u00ednh x\u00e1c t\u00ean c\u1ee7a t\u1eebng th\u01b0 m\u1ee5c v\u00e0 t\u1ec7p trong \u0111\u01b0\u1eddng d\u1eabn v\u00e0 t\u1ec7p class c\u1ee7a b\u1ea1n c\u00f3 t\u1ed3n t\u1ea1i trong \u0111\u01b0\u1eddng d\u1eabn \u0111\u00f3 hay kh\u00f4ng.<\/p>\n\n\n\n<p>Gi\u1ea3 s\u1eed, b\u1ea1n mu\u1ed1n ch\u1ea1y com.tino.HelloWorld \u1edf m\u1ed9t th\u01b0 m\u1ee5c kh\u00e1c, m\u1ed9t t\u1ec7p kh\u00e1c. B\u1ea1n s\u1ebd ph\u1ea3i l\u00e0m nh\u01b0 th\u1ebf n\u00e0o?<\/p>\n\n\n\n<p>R\u1ea5t may, nh\u00e0 ph\u00e1t tri\u1ec3n ng\u00f4n ng\u1eef Java c\u0169ng l\u00e0 l\u1eadp tr\u00ecnh vi\u00ean v\u00e0 t\u1ea1o \u0111i\u1ec1u ki\u1ec7n thu\u1eadn l\u1ee3i h\u01a1n trong vi\u1ec7c l\u1eadp tr\u00ecnh c\u1ee7a c\u00e1c b\u1ea1n b\u1eb1ng c\u00e1ch: s\u1eed d\u1ee5ng <strong>d\u1ea5u ch\u1ea5m \u2018.\u2019<\/strong> thay cho t\u00ean th\u01b0 m\u1ee5c l\u00e0 \u0111\u01b0\u1ee3c.<\/p>\n\n\n\n<p>Thay v\u00ec s\u1eed d\u1ee5ng:<strong> java -classpath &lt;t\u1ec7p m\u1eb9&gt;\/&lt;t\u1ec7p con&gt;\/ com.tino.HelloWorld<\/strong><\/p>\n\n\n\n<p>B\u1ea1n ch\u1ec9 c\u1ea7n thay v\u00e0o d\u1ea5u \u2018.\u2019:<strong> java -classpath .\/.\/ com.tino.HelloWorld<\/strong><\/p>\n\n\n\n<p>V\u1ea5n \u0111\u1ec1 c\u1ee7a b\u1ea1n s\u1ebd \u0111\u01b0\u1ee3c gi\u1ea3i quy\u1ebft nhanh h\u01a1n, \u00edt l\u1ed7i h\u01a1n.<\/p>\n\n\n\n<p>Trong tr\u01b0\u1eddng h\u1ee3p b\u1ea1n \u0111ang s\u1eed d\u1ee5ng c\u00e1c h\u1ec7 \u0111i\u1ec1u h\u00e0nh kh\u00e1c, b\u1ea1n c\u00f3 th\u1ec3 tham kh\u1ea3o t\u00e0i li\u1ec7u g\u1ed1c c\u1ee7a Oracle v\u1ec1 <a href=\"https:\/\/docs.oracle.com\/javase\/tutorial\/essential\/environment\/paths.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">PATH v\u00e0 CLASSPATH<\/a> \u0111\u1ec3 hi\u1ec3u r\u00f5 h\u01a1n nh\u00e9!<\/p>\n\n\n\n<p>Qua b\u00e0i vi\u1ebft, TinoHost hy v\u1ecdng \u0111\u00e3 c\u00f3 th\u1ec3 gi\u00fap b\u1ea1n gi\u1ea3i quy\u1ebft v\u00e0 s\u1eeda l\u1ed7i &#8220;Error: Could not find or load main class&#8221; th\u00e0nh c\u00f4ng! N\u1ebfu b\u1ea1n \u0111\u00e3 gi\u1ea3i quy\u1ebft th\u00e0nh c\u00f4ng, TinoHost r\u1ea5t vui v\u00ec \u0111\u00e3 gi\u00fap \u0111\u01b0\u1ee3c b\u1ea1n; n\u1ebfu ch\u01b0a, b\u1ea1n c\u00f3 th\u1ec3 th\u1eed l\u1ea1i th\u00eam l\u1ea7n n\u1eefa v\u00e0 TinoHost ch\u00fac b\u1ea1n th\u00e0nh c\u00f4ng! B\u1ea1n c\u00f3 c\u00e1ch gi\u1ea3i quy\u1ebft hay h\u01a1n v\u00e0 mu\u1ed1n chia s\u1ebb c\u00f9ng v\u1edbi c\u1ed9ng \u0111\u1ed3ng \u0111\u1ec3 S\u1eeda l\u1ed7i &#8220;Error: Could not find or load main class&#8221;? V\u1eady, b\u1ea1n \u0111\u1eebng ng\u1ea7n ng\u1ea1i li\u00ean h\u1ec7 \u0111\u1ec3 TinoHost c\u00f3 th\u1ec3 c\u1eadp nh\u1eadt ngay b\u00e0i vi\u1ebft nh\u00e9!<\/p>\n\n\n\n<h2 id=\"Nh\u1eefng_c\u00e2u_h\u1ecfi_th\u01b0\u1eddng_g\u1eb7p_v\u1ec1_s\u1eeda_l\u1ed7i_&#8220;Error:_Could_not_find_or_load_main_class&#8220;\"><a id=\"post-28525-_j6wxr2iu0h6t\"><\/a><strong>Nh\u1eefng c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 s\u1eeda l\u1ed7i &#8220;Error: Could not find or load main class<\/strong>&#8220;<\/h2>\n\n\n\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"T\u00ecm_hi\u1ec3u_c\u00e1c_l\u1ec7nh_c\u01a1_b\u1ea3n_c\u1ee7a_Java_\u1edf_\u0111\u00e2u?\">T\u00ecm hi\u1ec3u c\u00e1c l\u1ec7nh c\u01a1 b\u1ea3n c\u1ee7a Java \u1edf \u0111\u00e2u?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p>N\u1ebfu b\u1ea1n c\u00f3 kh\u1ea3 n\u0103ng ti\u1ebfng Anh t\u1ed1t, b\u1ea1n c\u00f3 th\u1ec3 xem <a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/technotes\/tools\/windows\/java.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">b\u1ed9 t\u00e0i li\u1ec7u h\u01b0\u1edbng d\u1eabn to\u00e0n t\u1eadp v\u1ec1 c\u00e1c l\u1ec7nh trong Java<\/a> c\u1ee7a Oracle.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"JDK_l\u00e0_g\u00ec?\">JDK l\u00e0 g\u00ec?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p><strong>JDK <\/strong>l\u00e0 vi\u1ebft t\u1eaft c\u1ee7a <strong>Java Development Kit<\/strong> l\u00e0 m\u1ed9t trong 3 th\u00e0nh ph\u1ea7n c\u00f4ng ngh\u1ec7 c\u1ed1t l\u00f5i \u0111\u1ec3 x\u00e2y d\u1ef1ng \u0111\u01b0\u1ee3c m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh Java.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"L\u00e0m_sao_\u0111\u1ec3_t\u1ea3i_JDK_mi\u1ec5n_ph\u00ed?\">L\u00e0m sao \u0111\u1ec3 t\u1ea3i JDK mi\u1ec5n ph\u00ed?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p>B\u1ea1n c\u00f3 th\u1ec3 t\u1ea3i to\u00e0n b\u1ed9 c\u00e1c phi\u00ean b\u1ea3n JDK ho\u00e0n to\u00e0n mi\u1ec5n ph\u00ed t\u1ea1i trang <a href=\"https:\/\/docs.oracle.com\/en\/java\/javase\/index.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Java Platform, Standard Edition Documentation<\/a> c\u1ee7a Oracle.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"Hello_World_l\u00e0_g\u00ec?\">Hello World l\u00e0 g\u00ec?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p>Hello World ch\u1ec9 \u0111\u01a1n gi\u1ea3n l\u00e0 m\u1ed9t d\u00f2ng ch\u1eef Hello World v\u00e0 h\u1ea7u h\u1ebft c\u00e1c l\u1eadp tr\u00ecnh vi\u00ean, s\u1eed d\u1ee5ng b\u1ea5t c\u1ee9 ng\u00f4n ng\u1eef n\u00e0o c\u0169ng \u0111\u00e3 t\u1eebng th\u1eed qua. Ch\u01b0\u01a1ng tr\u00ecnh Hello World \u0111\u01b0\u1ee3c vi\u1ebft \u0111\u1ea7u ti\u00ean b\u1edfi Brian Kernighan xu\u1ea5t b\u1ea3n trong cu\u1ed1n s\u00e1ch The C Programming Language xu\u1ea5t b\u1ea3n n\u0103m 1978.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"Thay_a_b\u1eb1ng_A_trong_Java_c\u00f3_\u0111\u01b0\u1ee3c_hay_kh\u00f4ng?\">Thay a b\u1eb1ng A trong Java c\u00f3 \u0111\u01b0\u1ee3c hay kh\u00f4ng?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p>Java c\u00f3 ph\u00e2n bi\u1ec7t ch\u1eef hoa ch\u1eef th\u01b0\u1eddng, v\u00ec th\u1ebf b\u1ea1n n\u00ean c\u1ea9n th\u1eadn khi g\u00f5 t\u00ean class \u0111\u1ec3 tr\u00e1nh l\u1ed7i &#8220;Error: Could not find or load main class&#8221; x\u1ea3y ra nh\u01b0 trong b\u00e0i \u0111\u00e3 \u0111\u1ec1 c\u1eadp.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\n<script type=\"application\/ld+json\">\n\t{\n\t\t\"@context\": \"https:\/\/schema.org\",\n\t\t\"@type\": \"FAQPage\",\n\t\t\"mainEntity\": [\n\t\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"T\u00ecm hi\u1ec3u c\u00e1c l\u1ec7nh c\u01a1 b\u1ea3n c\u1ee7a Java \u1edf \u0111\u00e2u?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>N\u1ebfu b\u1ea1n c\u00f3 kh\u1ea3 n\u0103ng ti\u1ebfng Anh t\u1ed1t, b\u1ea1n c\u00f3 th\u1ec3 xem <a>b\u1ed9 t\u00e0i li\u1ec7u h\u01b0\u1edbng d\u1eabn to\u00e0n t\u1eadp v\u1ec1 c\u00e1c l\u1ec7nh trong Java<\/a> c\u1ee7a Oracle.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"JDK l\u00e0 g\u00ec?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p><strong>JDK <\/strong>l\u00e0 vi\u1ebft t\u1eaft c\u1ee7a <strong>Java Development Kit<\/strong> l\u00e0 m\u1ed9t trong 3 th\u00e0nh ph\u1ea7n c\u00f4ng ngh\u1ec7 c\u1ed1t l\u00f5i \u0111\u1ec3 x\u00e2y d\u1ef1ng \u0111\u01b0\u1ee3c m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh Java.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"L\u00e0m sao \u0111\u1ec3 t\u1ea3i JDK mi\u1ec5n ph\u00ed?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>B\u1ea1n c\u00f3 th\u1ec3 t\u1ea3i to\u00e0n b\u1ed9 c\u00e1c phi\u00ean b\u1ea3n JDK ho\u00e0n to\u00e0n mi\u1ec5n ph\u00ed t\u1ea1i trang <a>Java Platform, Standard Edition Documentation<\/a> c\u1ee7a Oracle.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"Hello World l\u00e0 g\u00ec?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Hello World ch\u1ec9 \u0111\u01a1n gi\u1ea3n l\u00e0 m\u1ed9t d\u00f2ng ch\u1eef Hello World v\u00e0 h\u1ea7u h\u1ebft c\u00e1c l\u1eadp tr\u00ecnh vi\u00ean, s\u1eed d\u1ee5ng b\u1ea5t c\u1ee9 ng\u00f4n ng\u1eef n\u00e0o c\u0169ng \u0111\u00e3 t\u1eebng th\u1eed qua. Ch\u01b0\u01a1ng tr\u00ecnh Hello World \u0111\u01b0\u1ee3c vi\u1ebft \u0111\u1ea7u ti\u00ean b\u1edfi Brian Kernighan xu\u1ea5t b\u1ea3n trong cu\u1ed1n s\u00e1ch The C Programming Language xu\u1ea5t b\u1ea3n n\u0103m 1978.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"Thay a b\u1eb1ng A trong Java c\u00f3 \u0111\u01b0\u1ee3c hay kh\u00f4ng?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Java c\u00f3 ph\u00e2n bi\u1ec7t ch\u1eef hoa ch\u1eef th\u01b0\u1eddng, v\u00ec th\u1ebf b\u1ea1n n\u00ean c\u1ea9n th\u1eadn khi g\u00f5 t\u00ean class \u0111\u1ec3 tr\u00e1nh l\u1ed7i \\\"Error: Could not find or load main class\\\" x\u1ea3y ra nh\u01b0 trong b\u00e0i \u0111\u00e3 \u0111\u1ec1 c\u1eadp.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t\t\t\t]\n\t}\n<\/script>\n\n\n","protected":false},"excerpt":{"rendered":"<p>Trong khi s\u1eed d\u1ee5ng ng\u00f4n ng\u1eef Java \u0111\u1ec3 l\u1eadp tr\u00ecnh, kh\u00f4ng \u00edt nh\u1eefng ng\u01b0\u1eddi g\u1eb7p ph\u1ea3i l\u1ed7i &#8220;Error: Could not find or load main class&#8221;, \u0111\u1eb7c bi\u1ec7t l\u00e0 nh\u1eefng ng\u01b0\u1eddi m\u1edbi. Trong b\u00e0i vi\u1ebft n\u00e0y, TinoHost s\u1ebd gi\u00fap b\u1ea1n t\u00ecm hi\u1ec3u nguy\u00ean nh\u00e2n v\u00e0 \u0111\u01b0a ra gi\u1ea3i ph\u00e1p gi\u00fap b\u1ea1n \u0111\u1ec3 s\u1eeda l\u1ed7i &#8220;Error: Could [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":28755,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5404],"tags":[6187],"class_list":["post-28525","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-webmasters","tag-ho-tro-developer"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts\/28525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=28525"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts\/28525\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/28755"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=28525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/categories?post=28525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=28525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}