[{"data":1,"prerenderedAt":11084},["ShallowReactive",2],{"blog-posts-en-all":3},[4,1212,1332,1381,1637,1723,1761,1824,1933,2144,2209,2414,2642,2841,3049,3171,4000,5657,5876,6010,6675,6751,7081,7649,7769,8248,8789,9817,10712],{"id":5,"title":6,"body":7,"date":1201,"description":1202,"extension":1203,"meta":1204,"navigation":231,"path":1205,"seo":1206,"stem":1207,"tags":1208,"translation":1210,"__hash__":1211},"pages_en\u002Fen\u002Fblog\u002Fgit-commands-every-developer-should-know.md","Git Commands Every Developer Should Know",{"type":8,"value":9,"toc":1191},"minimark",[10,15,28,39,43,46,132,135,185,189,200,329,340,431,435,441,539,542,603,652,655,674,678,691,828,839,843,846,909,920,926,1007,1018,1054,1058,1061,1117,1120,1167,1171,1187],[11,12,14],"h2",{"id":13},"introduction","Introduction",[16,17,18,19,23,24,27],"p",{},"Most of your daily Git work is done with roughly 20 commands; this post collects them in order of use, with examples. Whether you're just starting out or have been using Git for years, bookmark this page for a quick reminder of the difference between ",[20,21,22],"code",{},"reset"," and ",[20,25,26],{},"revert",", or how to recover a lost commit.",[16,29,30,31,34,35,38],{},"The examples use ",[20,32,33],{},"main"," as the default branch and ",[20,36,37],{},"origin"," as the remote name.",[11,40,42],{"id":41},"_1-setup-and-configuration","1. Setup and configuration",[16,44,45],{},"When you first install Git, you only need to introduce yourself once; this information is written into every commit.",[47,48,53],"pre",{"className":49,"code":50,"language":51,"meta":52,"style":52},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","git config --global user.name \"Your Name\"\ngit config --global user.email \"you@example.com\"\ngit config --global init.defaultBranch main\ngit config --list          # show all settings\n","bash","",[20,54,55,84,103,118],{"__ignoreMap":52},[56,57,60,64,68,71,74,78,81],"span",{"class":58,"line":59},"line",1,[56,61,63],{"class":62},"sBMFI","git",[56,65,67],{"class":66},"sfazB"," config",[56,69,70],{"class":66}," --global",[56,72,73],{"class":66}," user.name",[56,75,77],{"class":76},"sMK4o"," \"",[56,79,80],{"class":66},"Your Name",[56,82,83],{"class":76},"\"\n",[56,85,87,89,91,93,96,98,101],{"class":58,"line":86},2,[56,88,63],{"class":62},[56,90,67],{"class":66},[56,92,70],{"class":66},[56,94,95],{"class":66}," user.email",[56,97,77],{"class":76},[56,99,100],{"class":66},"you@example.com",[56,102,83],{"class":76},[56,104,106,108,110,112,115],{"class":58,"line":105},3,[56,107,63],{"class":62},[56,109,67],{"class":66},[56,111,70],{"class":66},[56,113,114],{"class":66}," init.defaultBranch",[56,116,117],{"class":66}," main\n",[56,119,121,123,125,128],{"class":58,"line":120},4,[56,122,63],{"class":62},[56,124,67],{"class":66},[56,126,127],{"class":66}," --list",[56,129,131],{"class":130},"sHwdD","          # show all settings\n",[16,133,134],{},"To start a new project or download an existing repository:",[47,136,138],{"className":49,"code":137,"language":51,"meta":52,"style":52},"git init                                   # turn the current folder into a repo\ngit clone https:\u002F\u002Fgithub.com\u002Fuser\u002Fproject.git\ngit clone \u003Curl> new-folder-name            # clone into a different folder\n",[20,139,140,150,160],{"__ignoreMap":52},[56,141,142,144,147],{"class":58,"line":59},[56,143,63],{"class":62},[56,145,146],{"class":66}," init",[56,148,149],{"class":130},"                                   # turn the current folder into a repo\n",[56,151,152,154,157],{"class":58,"line":86},[56,153,63],{"class":62},[56,155,156],{"class":66}," clone",[56,158,159],{"class":66}," https:\u002F\u002Fgithub.com\u002Fuser\u002Fproject.git\n",[56,161,162,164,166,169,172,176,179,182],{"class":58,"line":105},[56,163,63],{"class":62},[56,165,156],{"class":66},[56,167,168],{"class":76}," \u003C",[56,170,171],{"class":66},"ur",[56,173,175],{"class":174},"sTEyZ","l",[56,177,178],{"class":76},">",[56,180,181],{"class":66}," new-folder-name",[56,183,184],{"class":130},"            # clone into a different folder\n",[11,186,188],{"id":187},"_2-everyday-workflow","2. Everyday workflow",[16,190,191,192,195,196,199],{},"Changes move through three stages: working directory → staging area (",[20,193,194],{},"add",") → repository history (",[20,197,198],{},"commit",").",[47,201,203],{"className":49,"code":202,"language":51,"meta":52,"style":52},"git status                 # what changed, what's staged\ngit status -s              # short format\n\ngit add File.java          # stage a single file\ngit add .                  # stage all changes\ngit add -p                 # stage changes interactively, chunk by chunk\n\ngit commit -m \"Add login validation\"\ngit commit -am \"Message\"   # add + commit tracked files\ngit commit --amend         # fix the last commit (before pushing!)\n",[20,204,205,215,227,233,246,259,272,277,295,316],{"__ignoreMap":52},[56,206,207,209,212],{"class":58,"line":59},[56,208,63],{"class":62},[56,210,211],{"class":66}," status",[56,213,214],{"class":130},"                 # what changed, what's staged\n",[56,216,217,219,221,224],{"class":58,"line":86},[56,218,63],{"class":62},[56,220,211],{"class":66},[56,222,223],{"class":66}," -s",[56,225,226],{"class":130},"              # short format\n",[56,228,229],{"class":58,"line":105},[56,230,232],{"emptyLinePlaceholder":231},true,"\n",[56,234,235,237,240,243],{"class":58,"line":120},[56,236,63],{"class":62},[56,238,239],{"class":66}," add",[56,241,242],{"class":66}," File.java",[56,244,245],{"class":130},"          # stage a single file\n",[56,247,249,251,253,256],{"class":58,"line":248},5,[56,250,63],{"class":62},[56,252,239],{"class":66},[56,254,255],{"class":66}," .",[56,257,258],{"class":130},"                  # stage all changes\n",[56,260,262,264,266,269],{"class":58,"line":261},6,[56,263,63],{"class":62},[56,265,239],{"class":66},[56,267,268],{"class":66}," -p",[56,270,271],{"class":130},"                 # stage changes interactively, chunk by chunk\n",[56,273,275],{"class":58,"line":274},7,[56,276,232],{"emptyLinePlaceholder":231},[56,278,280,282,285,288,290,293],{"class":58,"line":279},8,[56,281,63],{"class":62},[56,283,284],{"class":66}," commit",[56,286,287],{"class":66}," -m",[56,289,77],{"class":76},[56,291,292],{"class":66},"Add login validation",[56,294,83],{"class":76},[56,296,298,300,302,305,307,310,313],{"class":58,"line":297},9,[56,299,63],{"class":62},[56,301,284],{"class":66},[56,303,304],{"class":66}," -am",[56,306,77],{"class":76},[56,308,309],{"class":66},"Message",[56,311,312],{"class":76},"\"",[56,314,315],{"class":130},"   # add + commit tracked files\n",[56,317,319,321,323,326],{"class":58,"line":318},10,[56,320,63],{"class":62},[56,322,284],{"class":66},[56,324,325],{"class":66}," --amend",[56,327,328],{"class":130},"         # fix the last commit (before pushing!)\n",[16,330,331,332,335,336,339],{},"Use ",[20,333,334],{},"diff"," to see what changed and ",[20,337,338],{},"log"," to review history:",[47,341,343],{"className":49,"code":342,"language":51,"meta":52,"style":52},"git diff                   # unstaged changes\ngit diff --staged          # changes about to be committed\ngit log --oneline --graph --all   # readable branch history\ngit log -p File.java       # history of a single file\ngit show \u003Ccommit>          # details of one commit\ngit blame File.java        # who changed which line\n",[20,344,345,355,367,386,399,419],{"__ignoreMap":52},[56,346,347,349,352],{"class":58,"line":59},[56,348,63],{"class":62},[56,350,351],{"class":66}," diff",[56,353,354],{"class":130},"                   # unstaged changes\n",[56,356,357,359,361,364],{"class":58,"line":86},[56,358,63],{"class":62},[56,360,351],{"class":66},[56,362,363],{"class":66}," --staged",[56,365,366],{"class":130},"          # changes about to be committed\n",[56,368,369,371,374,377,380,383],{"class":58,"line":105},[56,370,63],{"class":62},[56,372,373],{"class":66}," log",[56,375,376],{"class":66}," --oneline",[56,378,379],{"class":66}," --graph",[56,381,382],{"class":66}," --all",[56,384,385],{"class":130},"   # readable branch history\n",[56,387,388,390,392,394,396],{"class":58,"line":120},[56,389,63],{"class":62},[56,391,373],{"class":66},[56,393,268],{"class":66},[56,395,242],{"class":66},[56,397,398],{"class":130},"       # history of a single file\n",[56,400,401,403,406,408,411,414,416],{"class":58,"line":248},[56,402,63],{"class":62},[56,404,405],{"class":66}," show",[56,407,168],{"class":76},[56,409,410],{"class":66},"commi",[56,412,413],{"class":174},"t",[56,415,178],{"class":76},[56,417,418],{"class":130},"          # details of one commit\n",[56,420,421,423,426,428],{"class":58,"line":261},[56,422,63],{"class":62},[56,424,425],{"class":66}," blame",[56,427,242],{"class":66},[56,429,430],{"class":130},"        # who changed which line\n",[11,432,434],{"id":433},"_3-branching","3. Branching",[16,436,437,438,440],{},"Opening a separate branch for every feature or bug fix is the easiest way to keep ",[20,439,33],{}," clean.",[47,442,444],{"className":49,"code":443,"language":51,"meta":52,"style":52},"git branch                 # local branches\ngit branch -a              # including remote branches\ngit switch -c feature\u002Flogin     # create and switch to a new branch\ngit switch main                 # switch branches\ngit checkout -b feature\u002Flogin   # older syntax, same job\ngit branch -d feature\u002Flogin     # delete a merged branch\ngit branch -D feature\u002Flogin     # force delete\n",[20,445,446,456,468,484,496,511,525],{"__ignoreMap":52},[56,447,448,450,453],{"class":58,"line":59},[56,449,63],{"class":62},[56,451,452],{"class":66}," branch",[56,454,455],{"class":130},"                 # local branches\n",[56,457,458,460,462,465],{"class":58,"line":86},[56,459,63],{"class":62},[56,461,452],{"class":66},[56,463,464],{"class":66}," -a",[56,466,467],{"class":130},"              # including remote branches\n",[56,469,470,472,475,478,481],{"class":58,"line":105},[56,471,63],{"class":62},[56,473,474],{"class":66}," switch",[56,476,477],{"class":66}," -c",[56,479,480],{"class":66}," feature\u002Flogin",[56,482,483],{"class":130},"     # create and switch to a new branch\n",[56,485,486,488,490,493],{"class":58,"line":120},[56,487,63],{"class":62},[56,489,474],{"class":66},[56,491,492],{"class":66}," main",[56,494,495],{"class":130},"                 # switch branches\n",[56,497,498,500,503,506,508],{"class":58,"line":248},[56,499,63],{"class":62},[56,501,502],{"class":66}," checkout",[56,504,505],{"class":66}," -b",[56,507,480],{"class":66},[56,509,510],{"class":130},"   # older syntax, same job\n",[56,512,513,515,517,520,522],{"class":58,"line":261},[56,514,63],{"class":62},[56,516,452],{"class":66},[56,518,519],{"class":66}," -d",[56,521,480],{"class":66},[56,523,524],{"class":130},"     # delete a merged branch\n",[56,526,527,529,531,534,536],{"class":58,"line":274},[56,528,63],{"class":62},[56,530,452],{"class":66},[56,532,533],{"class":66}," -D",[56,535,480],{"class":66},[56,537,538],{"class":130},"     # force delete\n",[16,540,541],{},"There are two ways to combine branches:",[47,543,545],{"className":49,"code":544,"language":51,"meta":52,"style":52},"git switch main\ngit merge feature\u002Flogin    # merge with a merge commit\ngit switch feature\u002Flogin\ngit rebase main            # replay commits on top of main\ngit rebase -i HEAD~3       # edit\u002Fsquash the last 3 commits\n",[20,546,547,555,567,576,588],{"__ignoreMap":52},[56,548,549,551,553],{"class":58,"line":59},[56,550,63],{"class":62},[56,552,474],{"class":66},[56,554,117],{"class":66},[56,556,557,559,562,564],{"class":58,"line":86},[56,558,63],{"class":62},[56,560,561],{"class":66}," merge",[56,563,480],{"class":66},[56,565,566],{"class":130},"    # merge with a merge commit\n",[56,568,569,571,573],{"class":58,"line":105},[56,570,63],{"class":62},[56,572,474],{"class":66},[56,574,575],{"class":66}," feature\u002Flogin\n",[56,577,578,580,583,585],{"class":58,"line":120},[56,579,63],{"class":62},[56,581,582],{"class":66}," rebase",[56,584,492],{"class":66},[56,586,587],{"class":130},"            # replay commits on top of main\n",[56,589,590,592,594,597,600],{"class":58,"line":248},[56,591,63],{"class":62},[56,593,582],{"class":66},[56,595,596],{"class":66}," -i",[56,598,599],{"class":66}," HEAD~3",[56,601,602],{"class":130},"       # edit\u002Fsquash the last 3 commits\n",[604,605,606,622],"table",{},[607,608,609],"thead",{},[610,611,612,616,619],"tr",{},[613,614,615],"th",{},"Command",[613,617,618],{},"What it does",[613,620,621],{},"When to use",[623,624,625,639],"tbody",{},[610,626,627,633,636],{},[628,629,630],"td",{},[20,631,632],{},"merge",[628,634,635],{},"Preserves history, adds a merge commit",[628,637,638],{},"On shared branches",[610,640,641,646,649],{},[628,642,643],{},[20,644,645],{},"rebase",[628,647,648],{},"Makes history linear",[628,650,651],{},"On local branches not yet pushed",[16,653,654],{},"Golden rule: never rebase a pushed branch that others also use.",[16,656,657,658,661,662,665,666,669,670,673],{},"If a conflict occurs, fix the files, run ",[20,659,660],{},"git add",", then continue with ",[20,663,664],{},"git merge --continue"," or ",[20,667,668],{},"git rebase --continue","; use ",[20,671,672],{},"--abort"," to give up.",[11,675,677],{"id":676},"_4-working-with-remotes","4. Working with remotes",[16,679,680,683,684,687,688,690],{},[20,681,682],{},"fetch"," only downloads; ",[20,685,686],{},"pull"," downloads and merges. When in doubt, ",[20,689,682],{}," first and see what's coming in.",[47,692,694],{"className":49,"code":693,"language":51,"meta":52,"style":52},"git remote -v                          # linked remotes\ngit remote add origin \u003Curl>            # add a remote\n\ngit fetch origin                       # download changes, don't merge\ngit pull                               # fetch + merge\ngit pull --rebase                      # fetch + rebase (cleaner history)\n\ngit push                               # push the current branch\ngit push -u origin feature\u002Flogin       # first push, set upstream\ngit push --force-with-lease            # safe force-push after a rebase\ngit push origin --delete feature\u002Flogin # delete a remote branch\n",[20,695,696,709,731,735,747,757,769,773,783,799,811],{"__ignoreMap":52},[56,697,698,700,703,706],{"class":58,"line":59},[56,699,63],{"class":62},[56,701,702],{"class":66}," remote",[56,704,705],{"class":66}," -v",[56,707,708],{"class":130},"                          # linked remotes\n",[56,710,711,713,715,717,720,722,724,726,728],{"class":58,"line":86},[56,712,63],{"class":62},[56,714,702],{"class":66},[56,716,239],{"class":66},[56,718,719],{"class":66}," origin",[56,721,168],{"class":76},[56,723,171],{"class":66},[56,725,175],{"class":174},[56,727,178],{"class":76},[56,729,730],{"class":130},"            # add a remote\n",[56,732,733],{"class":58,"line":105},[56,734,232],{"emptyLinePlaceholder":231},[56,736,737,739,742,744],{"class":58,"line":120},[56,738,63],{"class":62},[56,740,741],{"class":66}," fetch",[56,743,719],{"class":66},[56,745,746],{"class":130},"                       # download changes, don't merge\n",[56,748,749,751,754],{"class":58,"line":248},[56,750,63],{"class":62},[56,752,753],{"class":66}," pull",[56,755,756],{"class":130},"                               # fetch + merge\n",[56,758,759,761,763,766],{"class":58,"line":261},[56,760,63],{"class":62},[56,762,753],{"class":66},[56,764,765],{"class":66}," --rebase",[56,767,768],{"class":130},"                      # fetch + rebase (cleaner history)\n",[56,770,771],{"class":58,"line":274},[56,772,232],{"emptyLinePlaceholder":231},[56,774,775,777,780],{"class":58,"line":279},[56,776,63],{"class":62},[56,778,779],{"class":66}," push",[56,781,782],{"class":130},"                               # push the current branch\n",[56,784,785,787,789,792,794,796],{"class":58,"line":297},[56,786,63],{"class":62},[56,788,779],{"class":66},[56,790,791],{"class":66}," -u",[56,793,719],{"class":66},[56,795,480],{"class":66},[56,797,798],{"class":130},"       # first push, set upstream\n",[56,800,801,803,805,808],{"class":58,"line":318},[56,802,63],{"class":62},[56,804,779],{"class":66},[56,806,807],{"class":66}," --force-with-lease",[56,809,810],{"class":130},"            # safe force-push after a rebase\n",[56,812,814,816,818,820,823,825],{"class":58,"line":813},11,[56,815,63],{"class":62},[56,817,779],{"class":66},[56,819,719],{"class":66},[56,821,822],{"class":66}," --delete",[56,824,480],{"class":66},[56,826,827],{"class":130}," # delete a remote branch\n",[16,829,830,831,834,835,838],{},"Always use ",[20,832,833],{},"--force-with-lease"," instead of ",[20,836,837],{},"--force",": it stops the push if someone else has pushed since you last looked.",[11,840,842],{"id":841},"_5-undoing-mistakes","5. Undoing mistakes",[16,844,845],{},"The right command depends on what you want to undo:",[604,847,848,857],{},[607,849,850],{},[610,851,852,855],{},[613,853,854],{},"Situation",[613,856,615],{},[623,858,859,869,879,889,899],{},[610,860,861,864],{},[628,862,863],{},"Discard unsaved changes in a file",[628,865,866],{},[20,867,868],{},"git restore File.java",[610,870,871,874],{},[628,872,873],{},"Unstage a file",[628,875,876],{},[20,877,878],{},"git restore --staged File.java",[610,880,881,884],{},[628,882,883],{},"Undo the last commit, keep the changes",[628,885,886],{},[20,887,888],{},"git reset --soft HEAD~1",[610,890,891,894],{},[628,892,893],{},"Delete the last commit and its changes",[628,895,896],{},[20,897,898],{},"git reset --hard HEAD~1",[610,900,901,904],{},[628,902,903],{},"Safely undo a pushed commit",[628,905,906],{},[20,907,908],{},"git revert \u003Ccommit>",[16,910,911,913,914,916,917,919],{},[20,912,22],{}," rewrites history, while ",[20,915,26],{}," adds a new commit that undoes the change; always use ",[20,918,26],{}," on shared branches.",[16,921,331,922,925],{},[20,923,924],{},"stash"," to set aside unfinished work:",[47,927,929],{"className":49,"code":928,"language":51,"meta":52,"style":52},"git stash                      # stash your changes\ngit stash push -m \"half-done login\"   # stash with a name\ngit stash list                 # list stashes\ngit stash pop                  # apply and drop the latest stash\ngit stash apply stash@{1}      # apply a specific stash\n",[20,930,931,941,961,973,985],{"__ignoreMap":52},[56,932,933,935,938],{"class":58,"line":59},[56,934,63],{"class":62},[56,936,937],{"class":66}," stash",[56,939,940],{"class":130},"                      # stash your changes\n",[56,942,943,945,947,949,951,953,956,958],{"class":58,"line":86},[56,944,63],{"class":62},[56,946,937],{"class":66},[56,948,779],{"class":66},[56,950,287],{"class":66},[56,952,77],{"class":76},[56,954,955],{"class":66},"half-done login",[56,957,312],{"class":76},[56,959,960],{"class":130},"   # stash with a name\n",[56,962,963,965,967,970],{"class":58,"line":105},[56,964,63],{"class":62},[56,966,937],{"class":66},[56,968,969],{"class":66}," list",[56,971,972],{"class":130},"                 # list stashes\n",[56,974,975,977,979,982],{"class":58,"line":120},[56,976,63],{"class":62},[56,978,937],{"class":66},[56,980,981],{"class":66}," pop",[56,983,984],{"class":130},"                  # apply and drop the latest stash\n",[56,986,987,989,991,994,997,1001,1004],{"class":58,"line":248},[56,988,63],{"class":62},[56,990,937],{"class":66},[56,992,993],{"class":66}," apply",[56,995,996],{"class":66}," stash@{",[56,998,1000],{"class":999},"sbssI","1",[56,1002,1003],{"class":66},"}",[56,1005,1006],{"class":130},"      # apply a specific stash\n",[16,1008,1009,1010,1013,1014,1017],{},"Your last resort is ",[20,1011,1012],{},"reflog",": even commits \"lost\" after ",[20,1015,1016],{},"reset --hard"," show up here.",[47,1019,1021],{"className":49,"code":1020,"language":51,"meta":52,"style":52},"git reflog                     # everywhere HEAD has been\ngit reset --hard HEAD@{2}      # go back to that point\n",[20,1022,1023,1033],{"__ignoreMap":52},[56,1024,1025,1027,1030],{"class":58,"line":59},[56,1026,63],{"class":62},[56,1028,1029],{"class":66}," reflog",[56,1031,1032],{"class":130},"                     # everywhere HEAD has been\n",[56,1034,1035,1037,1040,1043,1046,1049,1051],{"class":58,"line":86},[56,1036,63],{"class":62},[56,1038,1039],{"class":66}," reset",[56,1041,1042],{"class":66}," --hard",[56,1044,1045],{"class":66}," HEAD@{",[56,1047,1048],{"class":999},"2",[56,1050,1003],{"class":66},[56,1052,1053],{"class":130},"      # go back to that point\n",[11,1055,1057],{"id":1056},"_6-time-saving-tips","6. Time-saving tips",[16,1059,1060],{},"Define aliases for commands you type often:",[47,1062,1064],{"className":49,"code":1063,"language":51,"meta":52,"style":52},"git config --global alias.st status\ngit config --global alias.co checkout\ngit config --global alias.lg \"log --oneline --graph --all\"\n# Now: git st, git lg\n",[20,1065,1066,1080,1094,1112],{"__ignoreMap":52},[56,1067,1068,1070,1072,1074,1077],{"class":58,"line":59},[56,1069,63],{"class":62},[56,1071,67],{"class":66},[56,1073,70],{"class":66},[56,1075,1076],{"class":66}," alias.st",[56,1078,1079],{"class":66}," status\n",[56,1081,1082,1084,1086,1088,1091],{"class":58,"line":86},[56,1083,63],{"class":62},[56,1085,67],{"class":66},[56,1087,70],{"class":66},[56,1089,1090],{"class":66}," alias.co",[56,1092,1093],{"class":66}," checkout\n",[56,1095,1096,1098,1100,1102,1105,1107,1110],{"class":58,"line":105},[56,1097,63],{"class":62},[56,1099,67],{"class":66},[56,1101,70],{"class":66},[56,1103,1104],{"class":66}," alias.lg",[56,1106,77],{"class":76},[56,1108,1109],{"class":66},"log --oneline --graph --all",[56,1111,83],{"class":76},[56,1113,1114],{"class":58,"line":120},[56,1115,1116],{"class":130},"# Now: git st, git lg\n",[16,1118,1119],{},"A few small habits make a big difference:",[1121,1122,1123,1142,1145,1151,1158],"ul",{},[1124,1125,1126,1127,1130,1131,1134,1135,1134,1138,1141],"li",{},"Add a ",[20,1128,1129],{},".gitignore"," file in the project's first commit (",[20,1132,1133],{},"target\u002F",", ",[20,1136,1137],{},"*.class",[20,1139,1140],{},".idea\u002F",", etc.).",[1124,1143,1144],{},"Write commit messages in the imperative mood and keep them short: \"Add login validation\".",[1124,1146,331,1147,1150],{},[20,1148,1149],{},"git bisect"," to binary-search for the commit that introduced a bug.",[1124,1152,1153,1154,1157],{},"Move a specific commit to another branch with ",[20,1155,1156],{},"git cherry-pick \u003Ccommit>",".",[1124,1159,1160,1161,23,1164,1157],{},"Tag releases with ",[20,1162,1163],{},"git tag -a v1.0 -m \"First release\"",[20,1165,1166],{},"git push --tags",[11,1168,1170],{"id":1169},"conclusion","Conclusion",[16,1172,1173,1174,23,1176,1178,1179,1134,1181,1183,1184,1186],{},"You'll memorize most of these commands in your first week; the lifesavers like ",[20,1175,1012],{},[20,1177,26],{}," are what you'll come back to this page for when you need them. The best practice is to open a throwaway repo and learn ",[20,1180,22],{},[20,1182,645],{},", and ",[20,1185,924],{}," by breaking things there.",[1188,1189,1190],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}",{"title":52,"searchDepth":86,"depth":86,"links":1192},[1193,1194,1195,1196,1197,1198,1199,1200],{"id":13,"depth":86,"text":14},{"id":41,"depth":86,"text":42},{"id":187,"depth":86,"text":188},{"id":433,"depth":86,"text":434},{"id":676,"depth":86,"text":677},{"id":841,"depth":86,"text":842},{"id":1056,"depth":86,"text":1057},{"id":1169,"depth":86,"text":1170},"2026-10-09","Most daily Git work runs on about 20 commands — here they are in order of use, with examples.","md",{},"\u002Fen\u002Fblog\u002Fgit-commands-every-developer-should-know",{"title":6,"description":1202},"en\u002Fblog\u002Fgit-commands-every-developer-should-know",[63,1209],"guide","\u002Fblog\u002Fgit-commands-every-developer-should-know","PvSpnP7Cj3MgLejGn28cYmBJKSVxzYbXhRcdX2nQisY",{"id":1213,"title":1214,"body":1215,"date":1322,"description":1323,"extension":1203,"meta":1324,"navigation":231,"path":1325,"seo":1326,"stem":1327,"tags":1328,"translation":1330,"__hash__":1331},"pages_en\u002Fen\u002Fblog\u002Fcreate-a-web-project-with-tailwind-css.md","Create a web project with Tailwind CSS",{"type":8,"value":1216,"toc":1313},[1217,1221,1229,1233,1239,1242,1246,1249,1255,1259,1262,1268,1272,1275,1281,1285,1288,1294,1298,1304,1307],[11,1218,1220],{"id":1219},"project-folder-and-nodejs-activation","Project folder and Node.js activation",[47,1222,1227],{"className":1223,"code":1225,"language":1226},[1224],"language-text","mkdir tailwind-demo\ncd tailwind-demo\nnpm init\n","text",[20,1228,1225],{"__ignoreMap":52},[11,1230,1232],{"id":1231},"install-tailwind-css","Install Tailwind CSS",[47,1234,1237],{"className":1235,"code":1236,"language":1226},[1224],"npm install -D tailwindcss\nnpx tailwindcss init\n",[20,1238,1236],{"__ignoreMap":52},[16,1240,1241],{},"You will have dev dependency for tailwind and tailwind.config.css",[11,1243,1245],{"id":1244},"configure-path","Configure path",[16,1247,1248],{},"Change content element like below to dedicate the directory.",[47,1250,1253],{"className":1251,"code":1252,"language":1226},[1224],"content: [\".\u002Fsrc\u002F**\u002F*.{html,js}\"],\n",[20,1254,1252],{"__ignoreMap":52},[11,1256,1258],{"id":1257},"add-tailwind-directives","Add Tailwind directives",[16,1260,1261],{},"Create src folder and input.css file. You will have src\u002Finput.css, then add below lines.",[47,1263,1266],{"className":1264,"code":1265,"language":1226},[1224],"@tailwind base;\n@tailwind components;\n@tailwind utilities;\n",[20,1267,1265],{"__ignoreMap":52},[11,1269,1271],{"id":1270},"tailwind-css-watch-tool-into-packagejson","Tailwind CSS Watch Tool into package.json",[16,1273,1274],{},"Add this watch script into your package.json scripts section. We will start our project with this command later.",[47,1276,1279],{"className":1277,"code":1278,"language":1226},[1224],"\"watch\": \"npx tailwindcss -i .\u002Fsrc\u002Finput.css -o .\u002Fdist\u002Foutput.css --watch\"\n",[20,1280,1278],{"__ignoreMap":52},[11,1282,1284],{"id":1283},"create-a-html-page-for-testing-purpose","Create a HTML page for testing purpose",[16,1286,1287],{},"Under src folder create an index.html file, then add below lines.",[47,1289,1292],{"className":1290,"code":1291,"language":1226},[1224],"\u003C!doctype html>\n\u003Chtml>\n\u003Chead>\n  \u003Cmeta charset=\"UTF-8\">\n  \u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  \u003Clink href=\"\u002Fdist\u002Foutput.css\" rel=\"stylesheet\">\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Ch1 class=\"text-3xl font-bold underline\">\n    Hello world!\n  \u003C\u002Fh1>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n",[20,1293,1291],{"__ignoreMap":52},[11,1295,1297],{"id":1296},"start-your-project","Start your project",[47,1299,1302],{"className":1300,"code":1301,"language":1226},[1224],"npm run watch\n",[20,1303,1301],{"__ignoreMap":52},[16,1305,1306],{},"Open index.html file in your browser by using LiveServer or another testing tool. You will see the page with Tailwind support. Enjoy.",[47,1308,1311],{"className":1309,"code":1310,"language":1226},[1224],"http:\u002F\u002F127.0.0.1:5500\u002Fsrc\u002Findex.html\n",[20,1312,1310],{"__ignoreMap":52},{"title":52,"searchDepth":86,"depth":86,"links":1314},[1315,1316,1317,1318,1319,1320,1321],{"id":1219,"depth":86,"text":1220},{"id":1231,"depth":86,"text":1232},{"id":1244,"depth":86,"text":1245},{"id":1257,"depth":86,"text":1258},{"id":1270,"depth":86,"text":1271},{"id":1283,"depth":86,"text":1284},{"id":1296,"depth":86,"text":1297},"2022-12-18","Setting up a web project with Tailwind CSS: project init, config paths, directives, and building the CSS.",{},"\u002Fen\u002Fblog\u002Fcreate-a-web-project-with-tailwind-css",{"title":1214,"description":1323},"en\u002Fblog\u002Fcreate-a-web-project-with-tailwind-css",[1329],"application servers","\u002Fblog\u002Fcreate-a-web-project-with-tailwind-css","At4s4Du2VFiO_0MtrNYmsiMGK76YqGt2cJTNb3prfmM",{"id":1333,"title":1334,"body":1335,"date":1372,"description":1373,"extension":1203,"meta":1374,"navigation":231,"path":1375,"seo":1376,"stem":1377,"tags":1378,"translation":1379,"__hash__":1380},"pages_en\u002Fen\u002Fblog\u002Finstall-go-on-centos.md","Install Go on CentOS",{"type":8,"value":1336,"toc":1367},[1337,1341,1347,1351,1357,1361],[11,1338,1340],{"id":1339},"check-version","Check Version",[47,1342,1345],{"className":1343,"code":1344,"language":1226},[1224],"go version\n",[20,1346,1344],{"__ignoreMap":52},[11,1348,1350],{"id":1349},"download-and-unzip","Download and Unzip",[47,1352,1355],{"className":1353,"code":1354,"language":1226},[1224],"wget https:\u002F\u002Fgo.dev\u002Fdl\u002Fgo1.18.5.linux-amd64.tar.gz\n\ntar -C \u002Fusr\u002Flocal -zxvf go1.18.5.linux-amd64.tar.gz\n",[20,1356,1354],{"__ignoreMap":52},[11,1358,1360],{"id":1359},"add-to-environment-variable-and-take-effect","Add to Environment Variable and Take Effect",[47,1362,1365],{"className":1363,"code":1364,"language":1226},[1224],"vi \u002Fetc\u002Fprofile\n\nexport PATH=$PATH:\u002Fusr\u002Flocal\u002Fgo\u002Fbin\n\nsource \u002Fetc\u002Fprofile\n",[20,1366,1364],{"__ignoreMap":52},{"title":52,"searchDepth":86,"depth":86,"links":1368},[1369,1370,1371],{"id":1339,"depth":86,"text":1340},{"id":1349,"depth":86,"text":1350},{"id":1359,"depth":86,"text":1360},"2022-10-31","Installing Go on CentOS: download, extract to \u002Fusr\u002Flocal, and PATH configuration.",{},"\u002Fen\u002Fblog\u002Finstall-go-on-centos",{"title":1334,"description":1373},"en\u002Fblog\u002Finstall-go-on-centos",[1329],"\u002Fblog\u002Finstall-go-on-centos","_qB76SgXwbOommOXW9jXJPBOQUSsSFWk8ot9jyoZnS8",{"id":1382,"title":1383,"body":1384,"date":1372,"description":1628,"extension":1203,"meta":1629,"navigation":231,"path":1630,"seo":1631,"stem":1632,"tags":1633,"translation":1635,"__hash__":1636},"pages_en\u002Fen\u002Fblog\u002Flinux-best-practices.md","Linux Best Practices",{"type":8,"value":1385,"toc":1626},[1386,1392,1410,1415,1442,1447,1467,1472,1504,1509,1536,1541,1553,1558,1567,1572,1585,1590,1623],[16,1387,1388],{},[1389,1390,1391],"strong",{},"CPU",[47,1393,1395],{"className":49,"code":1394,"language":51,"meta":52,"style":52},"lscpu\ncat \u002Fproc\u002Fcpuinfo\n",[20,1396,1397,1402],{"__ignoreMap":52},[56,1398,1399],{"class":58,"line":59},[56,1400,1401],{"class":62},"lscpu\n",[56,1403,1404,1407],{"class":58,"line":86},[56,1405,1406],{"class":62},"cat",[56,1408,1409],{"class":66}," \u002Fproc\u002Fcpuinfo\n",[16,1411,1412],{},[1389,1413,1414],{},"Memory Usage",[47,1416,1418],{"className":49,"code":1417,"language":51,"meta":52,"style":52},"free\ncat \u002Fproc\u002Fmeminfo\ntop\nhtop\n",[20,1419,1420,1425,1432,1437],{"__ignoreMap":52},[56,1421,1422],{"class":58,"line":59},[56,1423,1424],{"class":62},"free\n",[56,1426,1427,1429],{"class":58,"line":86},[56,1428,1406],{"class":62},[56,1430,1431],{"class":66}," \u002Fproc\u002Fmeminfo\n",[56,1433,1434],{"class":58,"line":105},[56,1435,1436],{"class":62},"top\n",[56,1438,1439],{"class":58,"line":120},[56,1440,1441],{"class":62},"htop\n",[16,1443,1444],{},[1389,1445,1446],{},"Disk Usage",[47,1448,1450],{"className":49,"code":1449,"language":51,"meta":52,"style":52},"df -h\ndu -h\n",[20,1451,1452,1460],{"__ignoreMap":52},[56,1453,1454,1457],{"class":58,"line":59},[56,1455,1456],{"class":62},"df",[56,1458,1459],{"class":66}," -h\n",[56,1461,1462,1465],{"class":58,"line":86},[56,1463,1464],{"class":62},"du",[56,1466,1459],{"class":66},[16,1468,1469],{},[1389,1470,1471],{},"OS Check",[47,1473,1475],{"className":49,"code":1474,"language":51,"meta":52,"style":52},"cat \u002Fetc\u002Fos-release\ncat \u002Fetc\u002Fsystem-release\nlsb_release -a\nsw_vers\n",[20,1476,1477,1484,1491,1499],{"__ignoreMap":52},[56,1478,1479,1481],{"class":58,"line":59},[56,1480,1406],{"class":62},[56,1482,1483],{"class":66}," \u002Fetc\u002Fos-release\n",[56,1485,1486,1488],{"class":58,"line":86},[56,1487,1406],{"class":62},[56,1489,1490],{"class":66}," \u002Fetc\u002Fsystem-release\n",[56,1492,1493,1496],{"class":58,"line":105},[56,1494,1495],{"class":62},"lsb_release",[56,1497,1498],{"class":66}," -a\n",[56,1500,1501],{"class":58,"line":120},[56,1502,1503],{"class":62},"sw_vers\n",[16,1505,1506],{},[1389,1507,1508],{},"Users",[47,1510,1512],{"className":49,"code":1511,"language":51,"meta":52,"style":52},"w\nwho\nusers\ncat \u002Fetc\u002Fpasswd\n",[20,1513,1514,1519,1524,1529],{"__ignoreMap":52},[56,1515,1516],{"class":58,"line":59},[56,1517,1518],{"class":62},"w\n",[56,1520,1521],{"class":58,"line":86},[56,1522,1523],{"class":62},"who\n",[56,1525,1526],{"class":58,"line":105},[56,1527,1528],{"class":62},"users\n",[56,1530,1531,1533],{"class":58,"line":120},[56,1532,1406],{"class":62},[56,1534,1535],{"class":66}," \u002Fetc\u002Fpasswd\n",[16,1537,1538],{},[1389,1539,1540],{},"Groups",[47,1542,1544],{"className":49,"code":1543,"language":51,"meta":52,"style":52},"cat \u002Fetc\u002Fgroup\n",[20,1545,1546],{"__ignoreMap":52},[56,1547,1548,1550],{"class":58,"line":59},[56,1549,1406],{"class":62},[56,1551,1552],{"class":66}," \u002Fetc\u002Fgroup\n",[16,1554,1555],{},[1389,1556,1557],{},"Change Password",[47,1559,1561],{"className":49,"code":1560,"language":51,"meta":52,"style":52},"passwd\n",[20,1562,1563],{"__ignoreMap":52},[56,1564,1565],{"class":58,"line":59},[56,1566,1560],{"class":62},[16,1568,1569],{},[1389,1570,1571],{},"Port Check",[47,1573,1575],{"className":49,"code":1574,"language":51,"meta":52,"style":52},"netstat -ant\n",[20,1576,1577],{"__ignoreMap":52},[56,1578,1579,1582],{"class":58,"line":59},[56,1580,1581],{"class":62},"netstat",[56,1583,1584],{"class":66}," -ant\n",[16,1586,1587],{},[1389,1588,1589],{},"Change Directory",[604,1591,1592,1601],{},[607,1593,1594],{},[610,1595,1596,1598],{},[613,1597,615],{},[613,1599,1600],{},"Description",[623,1602,1603,1613],{},[610,1604,1605,1610],{},[628,1606,1607],{},[20,1608,1609],{},"cd \u002Fpath\u002Fto\u002Fyou\u002Fwant\u002Fto\u002Fgo",[628,1611,1612],{},"Changes to the directory you want",[610,1614,1615,1620],{},[628,1616,1617],{},[20,1618,1619],{},"cd -",[628,1621,1622],{},"Changes to the directory you were in before",[1188,1624,1625],{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":52,"searchDepth":86,"depth":86,"links":1627},[],"Frequently used Linux system commands and good practices: CPU, memory, disk, user, and port management.",{},"\u002Fen\u002Fblog\u002Flinux-best-practices",{"title":1383,"description":1628},"en\u002Fblog\u002Flinux-best-practices",[1634],"linux","\u002Fblog\u002Flinux-best-practices","BeZyv87_Pup3deTEK2bs-aHsFtueSWZZt7ElxQ61gQ4",{"id":1638,"title":1639,"body":1640,"date":1714,"description":1715,"extension":1203,"meta":1716,"navigation":231,"path":1717,"seo":1718,"stem":1719,"tags":1720,"translation":1721,"__hash__":1722},"pages_en\u002Fen\u002Fblog\u002Fsftp-configuration-on-centos.md","SFTP Configuration on CentOS",{"type":8,"value":1641,"toc":1706},[1642,1652,1656,1662,1666,1672,1676,1682,1686,1692,1696,1702],[16,1643,1644,1645,1157],{},"It is a cheat sheet for SFTP configuration on CentOS. Long version is on ",[1646,1647,1651],"a",{"href":1648,"rel":1649},"https:\u002F\u002Fwww.digitalocean.com\u002Fcommunity\u002Ftutorials\u002Fhow-to-enable-sftp-without-shell-access-on-centos-7",[1650],"nofollow","DigitalOcean",[11,1653,1655],{"id":1654},"create-a-user","Create a User",[47,1657,1660],{"className":1658,"code":1659,"language":1226},[1224],"sudo adduser xfiles\nsudo passwd xfiles\n",[20,1661,1659],{"__ignoreMap":52},[11,1663,1665],{"id":1664},"create-a-directory-for-file-transfers","Create a Directory for File Transfers",[47,1667,1670],{"className":1668,"code":1669,"language":1226},[1224],"sudo mkdir -p \u002Fvar\u002Fsftp\u002Fuploads\nsudo chown root:root \u002Fvar\u002Fsftp\nsudo chmod 755 \u002Fvar\u002Fsftp\nsudo chown xfiles:xfiles \u002Fvar\u002Fsftp\u002Fuploads\n",[20,1671,1669],{"__ignoreMap":52},[11,1673,1675],{"id":1674},"configure-ssh-deamon","Configure SSH Deamon",[47,1677,1680],{"className":1678,"code":1679,"language":1226},[1224],"sudo vi \u002Fetc\u002Fssh\u002Fsshd_config\n\nMatch User xfiles\nForceCommand internal-sftp\nPasswordAuthentication yes\nChrootDirectory \u002Fvar\u002Fsftp\nPermitTunnel no\nAllowAgentForwarding no\nAllowTcpForwarding no\nX11Forwarding no\n",[20,1681,1679],{"__ignoreMap":52},[11,1683,1685],{"id":1684},"restart-ssd-deamon","Restart SSD Deamon",[47,1687,1690],{"className":1688,"code":1689,"language":1226},[1224],"sudo systemctl restart sshd\n",[20,1691,1689],{"__ignoreMap":52},[11,1693,1695],{"id":1694},"test-in-the-server","Test in the Server",[47,1697,1700],{"className":1698,"code":1699,"language":1226},[1224],"sftp xfiles@localhost\n",[20,1701,1699],{"__ignoreMap":52},[11,1703,1705],{"id":1704},"well-done","Well Done!",{"title":52,"searchDepth":86,"depth":86,"links":1707},[1708,1709,1710,1711,1712,1713],{"id":1654,"depth":86,"text":1655},{"id":1664,"depth":86,"text":1665},{"id":1674,"depth":86,"text":1675},{"id":1684,"depth":86,"text":1685},{"id":1694,"depth":86,"text":1695},{"id":1704,"depth":86,"text":1705},"2021-06-20","Configuring an SFTP-only user and upload directory on CentOS via sshd_config.",{},"\u002Fen\u002Fblog\u002Fsftp-configuration-on-centos",{"title":1639,"description":1715},"en\u002Fblog\u002Fsftp-configuration-on-centos",[1329],"\u002Fblog\u002Fsftp-configuration-on-centos","yfbjpzwXy9LqFf4VAOsu2t96kIgMdIaFy6ceixTFLMo",{"id":1724,"title":1725,"body":1726,"date":1751,"description":1752,"extension":1203,"meta":1753,"navigation":231,"path":1754,"seo":1755,"stem":1756,"tags":1757,"translation":1759,"__hash__":1760},"pages_en\u002Fen\u002Fblog\u002Finstall-java-on-centos-7-rhel-7.md","Installing Java on CentOS 7 & Red Hat Enterprise Linux 7",{"type":8,"value":1727,"toc":1749},[1728],[1729,1730,1731,1734,1737,1740,1743,1746],"ol",{},[1124,1732,1733],{},"sudo -i",[1124,1735,1736],{},"yum update",[1124,1738,1739],{},"yum list available java*",[1124,1741,1742],{},"yum install java-11-openjdk",[1124,1744,1745],{},"alternatives –config java",[1124,1747,1748],{},"choose the one you want",{"title":52,"searchDepth":86,"depth":86,"links":1750},[],"2019-11-08","Installing Java 11 (OpenJDK) on CentOS 7 and RHEL 7 with yum, plus picking an alternative version — a short step-by-step guide.",{},"\u002Fen\u002Fblog\u002Finstall-java-on-centos-7-rhel-7",{"title":1725,"description":1752},"en\u002Fblog\u002Finstall-java-on-centos-7-rhel-7",[1758,1634],"java","\u002Fblog\u002Finstall-java-on-centos-7-rhel-7","ejhY0ORZmFzU53wpLWWuDgYcA2er-JjIqGwADkjrDoA",{"id":1762,"title":1763,"body":1764,"date":1751,"description":1816,"extension":1203,"meta":1817,"navigation":231,"path":1818,"seo":1819,"stem":1820,"tags":1821,"translation":1822,"__hash__":1823},"pages_en\u002Fen\u002Fblog\u002Frhel-remote-desktop-with-vnc.md","RHEL Remote Desktop with VNC",{"type":8,"value":1765,"toc":1814},[1766,1805,1811],[1729,1767,1768,1774,1780,1786,1796,1802],{},[1124,1769,1770,1771],{},"First we need to install a desktop environment.\n",[20,1772,1773],{},"yum groupinstall \"GNOME Desktop\"",[1124,1775,1776,1777],{},"We need to install the TigerVNC server along with its fonts.\n",[20,1778,1779],{},"yum install tigervnc-server xorg-x11-fonts-Type1",[1124,1781,1782,1783],{},"Let's create a service so it can serve on port 5903.\n",[20,1784,1785],{},"cp \u002Flib\u002Fsystemd\u002Fsystem\u002Fvncserver@.service \u002Fetc\u002Fsystemd\u002Fsystem\u002Fvncserver@:3.service",[1124,1787,1788,1789,1792,1793],{},"Update the user information by replacing every ",[20,1790,1791],{},"\u003CUSER>"," field.\n",[20,1794,1795],{},"vi \u002Fetc\u002Fsystemd\u002Fsystem\u002Fvncserver@:3.service",[1124,1797,1798,1799],{},"Switch to the relevant user and create a VNC user and password.\n",[20,1800,1801],{},"vncserver",[1124,1803,1804],{},"Enable and start the daemon with the commands below.",[47,1806,1809],{"className":1807,"code":1808,"language":1226},[1224],"systemctl daemon-reload\nsystemctl start vncserver@:3.service\nsystemctl enable vncserver@:3.service\n",[20,1810,1808],{"__ignoreMap":52},[16,1812,1813],{},"Now we can connect with a VNC viewer 🙂",{"title":52,"searchDepth":86,"depth":86,"links":1815},[],"Setting up a VNC remote desktop connection to a RHEL server.",{},"\u002Fen\u002Fblog\u002Frhel-remote-desktop-with-vnc",{"title":1763,"description":1816},"en\u002Fblog\u002Frhel-remote-desktop-with-vnc",[1634],"\u002Fblog\u002Frhel-remote-desktop-with-vnc","yjpO2ILKPf9bWQF2_AtQ46Sx0ag5d0ONMGRAUdl4JF4",{"id":1825,"title":1826,"body":1827,"date":1924,"description":1925,"extension":1203,"meta":1926,"navigation":231,"path":1927,"seo":1928,"stem":1929,"tags":1930,"translation":1931,"__hash__":1932},"pages_en\u002Fen\u002Fblog\u002Flinux-x11-forwarding.md","Linux X11Forwarding",{"type":8,"value":1828,"toc":1922},[1829,1832,1919],[16,1830,1831],{},"To pull the display of a Linux server onto our own desktop we need to enable X11Forwarding. We can do that with the commands below.",[47,1833,1835],{"className":49,"code":1834,"language":51,"meta":52,"style":52},"cat \u002Fetc\u002Fssh\u002Fsshd_config\nvi \u002Fetc\u002Fssh\u002Fsshd_config\n\n# inside sshd_config:\nAddressFamily inet\nX11Forwarding yes\n\nservice sshd restart\n\ntouch \u002Fhome\u002Fuser\u002F.Xauthority\nxauth list\nxauth add\n",[20,1836,1837,1844,1851,1855,1860,1868,1876,1880,1891,1895,1903,1911],{"__ignoreMap":52},[56,1838,1839,1841],{"class":58,"line":59},[56,1840,1406],{"class":62},[56,1842,1843],{"class":66}," \u002Fetc\u002Fssh\u002Fsshd_config\n",[56,1845,1846,1849],{"class":58,"line":86},[56,1847,1848],{"class":62},"vi",[56,1850,1843],{"class":66},[56,1852,1853],{"class":58,"line":105},[56,1854,232],{"emptyLinePlaceholder":231},[56,1856,1857],{"class":58,"line":120},[56,1858,1859],{"class":130},"# inside sshd_config:\n",[56,1861,1862,1865],{"class":58,"line":248},[56,1863,1864],{"class":62},"AddressFamily",[56,1866,1867],{"class":66}," inet\n",[56,1869,1870,1873],{"class":58,"line":261},[56,1871,1872],{"class":62},"X11Forwarding",[56,1874,1875],{"class":66}," yes\n",[56,1877,1878],{"class":58,"line":274},[56,1879,232],{"emptyLinePlaceholder":231},[56,1881,1882,1885,1888],{"class":58,"line":279},[56,1883,1884],{"class":62},"service",[56,1886,1887],{"class":66}," sshd",[56,1889,1890],{"class":66}," restart\n",[56,1892,1893],{"class":58,"line":297},[56,1894,232],{"emptyLinePlaceholder":231},[56,1896,1897,1900],{"class":58,"line":318},[56,1898,1899],{"class":62},"touch",[56,1901,1902],{"class":66}," \u002Fhome\u002Fuser\u002F.Xauthority\n",[56,1904,1905,1908],{"class":58,"line":813},[56,1906,1907],{"class":62},"xauth",[56,1909,1910],{"class":66}," list\n",[56,1912,1914,1916],{"class":58,"line":1913},12,[56,1915,1907],{"class":62},[56,1917,1918],{"class":66}," add\n",[1188,1920,1921],{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":52,"searchDepth":86,"depth":86,"links":1923},[],"2019-11-05","Enabling X11Forwarding over SSH to bring a Linux server's graphical display to your local desktop.",{},"\u002Fen\u002Fblog\u002Flinux-x11-forwarding",{"title":1826,"description":1925},"en\u002Fblog\u002Flinux-x11-forwarding",[1329],"\u002Fblog\u002Flinux-x11-forwarding","wmS3QQT91mqrNKwYIUZ3XlSTY1OT9aF3QDcm3AyuIxc",{"id":1934,"title":1935,"body":1936,"date":2134,"description":2135,"extension":1203,"meta":2136,"navigation":231,"path":2137,"seo":2138,"stem":2139,"tags":2140,"translation":2142,"__hash__":2143},"pages_en\u002Fen\u002Fblog\u002Fdocker-cheat-sheet.md","Docker Cheat Sheet",{"type":8,"value":1937,"toc":2121},[1938,1942,1948,1952,1957,1961,1967,1971,1977,1981,1986,1990,1995,1999,2005,2009,2014,2018,2023,2027,2032,2036,2041,2046,2051,2056,2061,2066,2071,2076,2081,2086,2091,2096,2101,2106,2111,2116],[11,1939,1941],{"id":1940},"docker-version-and-info","Docker Version and Info",[47,1943,1946],{"className":1944,"code":1945,"language":1226},[1224],"docker -v\ndocker info\n",[20,1947,1945],{"__ignoreMap":52},[11,1949,1951],{"id":1950},"list-images","List Images",[16,1953,1954],{},[20,1955,1956],{},"docker images",[11,1958,1960],{"id":1959},"list-containers-running-all","List Containers (running, all)",[47,1962,1965],{"className":1963,"code":1964,"language":1226},[1224],"docker container ls\ndocker container ls --all\ndocker ps\ndocker ps -a\n",[20,1966,1964],{"__ignoreMap":52},[11,1968,1970],{"id":1969},"run-a-new-container","Run a New Container",[47,1972,1975],{"className":1973,"code":1974,"language":1226},[1224],"docker run \u003Cimage-name>\ndocker run --name \u003Cname> \u003Cimage-name>\ndocker run -p \u003Couter-port>:\u003Cinner-port> \u003Cimage-name>\ndocker run -d -p \u003Couter-port>:\u003Cinner-port> \u003Cimage-name>\n",[20,1976,1974],{"__ignoreMap":52},[11,1978,1980],{"id":1979},"start-a-container","Start a Container",[16,1982,1983],{},[20,1984,1985],{},"docker start \u003Cname>",[11,1987,1989],{"id":1988},"stop-a-container","Stop a Container",[16,1991,1992],{},[20,1993,1994],{},"docker stop \u003Cname>",[11,1996,1998],{"id":1997},"remove-a-container","Remove a Container",[47,2000,2003],{"className":2001,"code":2002,"language":1226},[1224],"docker rm \u003Ccontainer-id>\ndocker rm -f \u003Ccontainer-id>\n",[20,2004,2002],{"__ignoreMap":52},[11,2006,2008],{"id":2007},"remove-an-image","Remove an Image",[16,2010,2011],{},[20,2012,2013],{},"docker rmi \u003Cimage-name>",[11,2015,2017],{"id":2016},"remove-all-stopped-containers","Remove All Stopped Containers",[16,2019,2020],{},[20,2021,2022],{},"docker container prune",[11,2024,2026],{"id":2025},"remove-all-unused-images","Remove All Unused Images",[16,2028,2029],{},[20,2030,2031],{},"docker image prune -a",[11,2033,2035],{"id":2034},"connect-to-docker-via-bash","Connect to Docker via Bash",[16,2037,2038],{},[20,2039,2040],{},"docker exec -it \u003Cname> bash",[16,2042,2043],{},[1389,2044,2045],{},"Install Docker",[16,2047,2048],{},[20,2049,2050],{},"yum install docker",[16,2052,2053],{},[1389,2054,2055],{},"Start Docker Deamon",[16,2057,2058],{},[20,2059,2060],{},"systemctl start docker",[16,2062,2063],{},[1389,2064,2065],{},"Create a Postgres Container",[16,2067,2068],{},[20,2069,2070],{},"docker run -d --name my-postgres -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres",[16,2072,2073],{},[1389,2074,2075],{},"Create a Keycloak Server",[16,2077,2078],{},[20,2079,2080],{},"docker run -d --name my-keycloak -e KEYCLOAK_USER=keyadmin -e KEYCLOAK_PASSWORD=keypass -p 7000:8080 jboss\u002Fkeycloak",[16,2082,2083],{},[1389,2084,2085],{},"Create a Konga Admin GUI",[16,2087,2088],{},[20,2089,2090],{},"docker run -d --name my-konga -p 1337:1337 -e \"TOKEN_SECRET=somerandomstring\" -e \"DB_ADAPTER=postgres\" -e \"DB_HOST=kong-database\" -e \"DB_PORT=5432\" -e \"DB_USER=kong\" -e \"DB_PASSWORD=kong\" -e \"DB_DATABASE=konga\" -e \"NODE_ENV=development\" --net=kong-net pantsel\u002Fkonga",[16,2092,2093],{},[1389,2094,2095],{},"Create a Docker Network",[16,2097,2098],{},[20,2099,2100],{},"docker network create --driver bridge kong-net",[16,2102,2103],{},[1389,2104,2105],{},"Connecting a Docker Container to a Network",[16,2107,2108],{},[20,2109,2110],{},"docker network connect kong-net kong-database",[16,2112,2113],{},[1389,2114,2115],{},"Docker Compose Pull",[16,2117,2118],{},[20,2119,2120],{},"docker-compose pull && docker-compose down && docker-compose up -d",{"title":52,"searchDepth":86,"depth":86,"links":2122},[2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,2133],{"id":1940,"depth":86,"text":1941},{"id":1950,"depth":86,"text":1951},{"id":1959,"depth":86,"text":1960},{"id":1969,"depth":86,"text":1970},{"id":1979,"depth":86,"text":1980},{"id":1988,"depth":86,"text":1989},{"id":1997,"depth":86,"text":1998},{"id":2007,"depth":86,"text":2008},{"id":2016,"depth":86,"text":2017},{"id":2025,"depth":86,"text":2026},{"id":2034,"depth":86,"text":2035},"2019-09-17","A Docker cheat sheet: images, containers, run flags, pruning, exec, networks, and common recipes.",{},"\u002Fen\u002Fblog\u002Fdocker-cheat-sheet",{"title":1935,"description":2135},"en\u002Fblog\u002Fdocker-cheat-sheet",[2141],"docker","\u002Fblog\u002Fdocker-cheat-sheet","3Td6enVQZeyw_p8uK8a8c3LePa-D7QPMbIejzRQG5d8",{"id":2145,"title":2146,"body":2147,"date":2200,"description":2201,"extension":1203,"meta":2202,"navigation":231,"path":2203,"seo":2204,"stem":2205,"tags":2206,"translation":2207,"__hash__":2208},"pages_en\u002Fen\u002Fblog\u002Fcreate-ssh-key-pair.md","Creating an SSH Key Pair",{"type":8,"value":2148,"toc":2197},[2149,2156,2160,2171,2194],[16,2150,2151,2152,2155],{},"For security, I prefer creating an SSH key pair and sharing the \"Public Key\" over using a \"username\"\u002F\"password\" for most of the places I connect to.\nIn this post I'll walk through creating a key pair on ",[1389,2153,2154],{},"Mac OS"," in detail.",[11,2157,2159],{"id":2158},"what-is-an-ssh-key-pair-secure-shell-key-pair","What Is an SSH Key Pair? (Secure Shell Key Pair)",[16,2161,2162,2163,2166,2167],{},"Secure Shell is a cryptographic network protocol that enables secure communication over an insecure network.\nSince my goal here is to create a private-public key pair, I'll generate an RSA key pair using \"asymmetric encryption\". Below you can see the features of the ",[1389,2164,2165],{},"ssh-keygen"," tool.\n",[2168,2169],"img",{"alt":52,"src":2170},"\u002Fimages\u002Fcreate-ssh-key-pair-Screenshot-2019-06-26-at-18.10.14.png",[1729,2172,2173,2179,2182,2185,2188],{},[1124,2174,2175,2176],{},"I'll run the following command in the terminal. It will help me generate an RSA key pair.\n",[20,2177,2178],{},"ssh-keygen -t rsa",[1124,2180,2181],{},"It will ask which file to save the key to — you can give it any name you like.",[1124,2183,2184],{},"After this step, you can optionally set a passphrase for using the keys.",[1124,2186,2187],{},"The output will look like the one below. Two keys were created: one private and one public. You must never share the private one with anyone.",[1124,2189,2190,2191],{},"Take the key from inside the public one (the file ending in .pub) and you can now share it.",[2168,2192],{"alt":52,"src":2193},"\u002Fimages\u002Fcreate-ssh-key-pair-Screenshot-2019-06-26-at-19.33.20.png",[16,2195,2196],{},"Take it easy.",{"title":52,"searchDepth":86,"depth":86,"links":2198},[2199],{"id":2158,"depth":86,"text":2159},"2019-06-26","Creating an SSH key pair with ssh-keygen and setting up passwordless server access.",{},"\u002Fen\u002Fblog\u002Fcreate-ssh-key-pair",{"title":2146,"description":2201},"en\u002Fblog\u002Fcreate-ssh-key-pair",[1329],"\u002Fblog\u002Fcreate-ssh-key-pair","ELXk6CP98Mp4qtFON_5rdcLU45lIguV5sgRIPu5R3fI",{"id":2210,"title":2211,"body":2212,"date":2405,"description":2406,"extension":1203,"meta":2407,"navigation":231,"path":2408,"seo":2409,"stem":2410,"tags":2411,"translation":2412,"__hash__":2413},"pages_en\u002Fen\u002Fblog\u002Fjava-11-12-13-and-beyond.md","Java 11-12-13 and Beyond",{"type":8,"value":2213,"toc":2399},[2214,2217,2231,2234,2238,2241,2247,2250,2254,2257,2274,2287,2300,2304,2315,2322,2329,2339,2345,2351,2363,2369,2373,2376,2379,2382,2384,2387],[16,2215,2216],{},"Hello, Java 11 brings important changes to the life of everyone who uses Java. I'll talk about them in this post.\nThe JDK (Java Development Kit) will now be updated every 6 months — in March and September each year. What we call LTS (Long Term Support) releases will come out every 3 years.",[1121,2218,2219,2222,2225,2228],{},[1124,2220,2221],{},"September 2018 – Java 11",[1124,2223,2224],{},"September 2021 – Java 17",[1124,2226,2227],{},"September 2024 – Java 23",[1124,2229,2230],{},"… and so on",[16,2232,2233],{},"And of course, those who pay can keep getting support beyond 3 years 🙂",[11,2235,2237],{"id":2236},"licensing-oracle-jdk-open-jdk","Licensing – Oracle JDK & Open JDK",[16,2239,2240],{},"With Java 11 we now have the concepts of Oracle JDK and Open JDK. From now on",[2242,2243,2244],"blockquote",{},[16,2245,2246],{},"Oracle JDK – Oracle Binary Code License Aggrement\nOpen JDK – GPL2",[16,2248,2249],{},"licenses will be part of our lives. GPL2 is fully open source and free. The Oracle Binary Code License is free while developing but will be paid in production environments.",[11,2251,2253],{"id":2252},"deprecated-and-removed-items","Deprecated and Removed Items",[16,2255,2256],{},"The following Enterprise APIs were removed from the JDK.",[1121,2258,2259,2262,2265,2268,2271],{},[1124,2260,2261],{},"JAXB – xml binding",[1124,2263,2264],{},"JAX-WS – xml web services and endpoint technology",[1124,2266,2267],{},"CORBA – distributed object technology",[1124,2269,2270],{},"JTA – java transaction api",[1124,2272,2273],{},"JavaBeans Activation",[16,2275,2276,2277,2281,2282],{},"Details here; ",[1646,2278,2279],{"href":2279,"rel":2280},"https:\u002F\u002Fopenjdk.java.net\u002Fjeps\u002F320",[1650],"\nAlso the destroy() and stop(Throwable obj) methods were removed from the Thread class.\nJDK 10 – ",[1646,2283,2286],{"href":2284,"rel":2285},"https:\u002F\u002Fdocs.oracle.com\u002Fjavase\u002F10\u002Fdocs\u002Fapi\u002Fjava\u002Flang\u002FThread.html",[1650],"Thread",[16,2288,2289,2290,2294,2295,1157],{},"JDK 11 – ",[1646,2291,2286],{"href":2292,"rel":2293},"https:\u002F\u002Fdocs.oracle.com\u002Fen\u002Fjava\u002Fjavase\u002F11\u002Fdocs\u002Fapi\u002Fjava.base\u002Fjava\u002Flang\u002FThread.html",[1650],"\nJavaFX was taken out of the JDK and turned into a separate library named ",[1646,2296,2299],{"href":2297,"rel":2298},"https:\u002F\u002Fopenjfx.io\u002F",[1650],"OpenJFX",[11,2301,2303],{"id":2302},"language-and-library-novelties","Language and Library Novelties",[16,2305,2306,2307,2310],{},"The HttpClient class, which existed experimentally in JDK 9 and 10 for sending HTTP requests and reading responses, is now live. Since it offers HTTP\u002F2 support, it's a reason to move to Java 11 for most new projects 🙂 I've added the API links below.\n",[2168,2308],{"alt":52,"src":2309},"\u002Fimages\u002Fjava-11-12-13-and-beyond-httpclient-1024x422.png",[1646,2311,2314],{"href":2312,"rel":2313},"https:\u002F\u002Fdocs.oracle.com\u002Fen\u002Fjava\u002Fjavase\u002F11\u002Fdocs\u002Fapi\u002Fjava.net.http\u002Fjava\u002Fnet\u002Fhttp\u002FHttpClient.html",[1650],"HttpClient API",[16,2316,2317],{},[1646,2318,2321],{"href":2319,"rel":2320},"https:\u002F\u002Fdocs.oracle.com\u002Fen\u002Fjava\u002Fjavase\u002F11\u002Fdocs\u002Fapi\u002Fjava.net.http\u002Fjava\u002Fnet\u002Fhttp\u002FHttpRequest.html",[1650],"HttpRequest API",[16,2323,2324],{},[1646,2325,2328],{"href":2326,"rel":2327},"https:\u002F\u002Fdocs.oracle.com\u002Fen\u002Fjava\u002Fjavase\u002F11\u002Fdocs\u002Fapi\u002Fjava.net.http\u002Fjava\u002Fnet\u002Fhttp\u002FHttpResponse.html",[1650],"HttpResponse API",[16,2330,2331,2332,2335,2338],{},"New handy methods were added to the String class.\n",[2168,2333],{"alt":52,"src":2334},"\u002Fimages\u002Fjava-11-12-13-and-beyond-string-246x300.png",[1389,2336,2337],{},"repeat","() – to repeat a string",[16,2340,2341,2344],{},[1389,2342,2343],{},"isBlank","() – checks whether a string is blank",[16,2346,2347,2350],{},[1389,2348,2349],{},"strip","() – unlike trim(), cleans whitespace characters at the start and end of a string including Unicode characters",[16,2352,2353,2356,2357,2362],{},[1389,2354,2355],{},"lines","() – lets us get the lines inside a string split on \"\\r\\n\" (line feed and carriage return characters) as a stream\nAlso the ",[1646,2358,2361],{"href":2359,"rel":2360},"https:\u002F\u002Fdocs.oracle.com\u002Fen\u002Fjava\u002Fjavase\u002F11\u002Fdocs\u002Fapi\u002Fjava.base\u002Fjava\u002Fnio\u002Ffile\u002FFiles.html",[1650],"Files"," class got the following new methods;",[16,2364,2365,2368],{},[2168,2366],{"alt":52,"src":2367},"\u002Fimages\u002Fjava-11-12-13-and-beyond-files.png","Unicode 10 support also comes with JDK 11.\nI only wrote the ones I think I'll use the most here. I'm adding the full list at the bottom of the post.",[11,2370,2372],{"id":2371},"performance-and-security-improvements","Performance and Security Improvements",[16,2374,2375],{},"With the G1 Garbage Collector, Java 11 shows 60% better performance than Java 8. That means we can get better performance just by upgrading to Java 11 without changing any of our code.\nTwo new GCs were also added: Epsilon GC and Z GC. Both are still experimental.\nEpsilon Garbage Collector can be used for performance measurement; it can be enabled with the parameters below.",[16,2377,2378],{},"XX:+UnlockExperimentalVMOptions",[16,2380,2381],{},"XX:+UseEpsilonGC\nZ Garbage Collector allows scaling to multi-terabyte heaps. It only works on 64-bit Linux machines.",[16,2383,2378],{},[16,2385,2386],{},"XX:+UseZGC\nOn the security side, TLS 1.3 support was added, cryptographical algorithms that lost their security were removed, and newer safer algorithms were added. Every message except the first one in the handshake is encrypted. Details at the link below.",[16,2388,2389,2393,2394],{},[1646,2390,2391],{"href":2391,"rel":2392},"https:\u002F\u002Fopenjdk.java.net\u002Fjeps\u002F332",[1650],"\nFinally, ",[1646,2395,2398],{"href":2396,"rel":2397},"https:\u002F\u002Fwww.oracle.com\u002Ftechnetwork\u002Fjava\u002Fjavase\u002F11-relnote-issues-5012449.html",[1650],"the Java 11 change list announced by Oracle is at this link.",{"title":52,"searchDepth":86,"depth":86,"links":2400},[2401,2402,2403,2404],{"id":2236,"depth":86,"text":2237},{"id":2252,"depth":86,"text":2253},{"id":2302,"depth":86,"text":2303},{"id":2371,"depth":86,"text":2372},"2019-02-13","What's new in Java 11 and later: the new release cadence and the standout features.",{},"\u002Fen\u002Fblog\u002Fjava-11-12-13-and-beyond",{"title":2211,"description":2406},"en\u002Fblog\u002Fjava-11-12-13-and-beyond",[1758],"\u002Fblog\u002Fjava-11-12-13-and-beyond","A6qbDSRQCicAZT_7f8Bh4LszB3qH-MdpiazRa5fBw5g",{"id":2415,"title":2416,"body":2417,"date":2632,"description":2633,"extension":1203,"meta":2634,"navigation":231,"path":2635,"seo":2636,"stem":2637,"tags":2638,"translation":2640,"__hash__":2641},"pages_en\u002Fen\u002Fblog\u002Finstall-mysql-on-centos-7.md","Installing MySQL on CentOS 7",{"type":8,"value":2418,"toc":2630},[2419,2422,2438,2446,2453,2471,2474,2491,2494,2512,2515,2530,2533,2536,2557,2560,2576,2579,2607,2610,2624,2627],[16,2420,2421],{},"CentOS uses yum as its package manager, so we need to update it first. We can do that with the command below.",[47,2423,2425],{"className":49,"code":2424,"language":51,"meta":52,"style":52},"sudo yum update\n",[20,2426,2427],{"__ignoreMap":52},[56,2428,2429,2432,2435],{"class":58,"line":59},[56,2430,2431],{"class":62},"sudo",[56,2433,2434],{"class":66}," yum",[56,2436,2437],{"class":66}," update\n",[16,2439,2440,2441,2445],{},"Once the update finishes we need to pick the MySQL server version we want to download. Let's select our version from the MySQL download page (",[1646,2442,2443],{"href":2443,"rel":2444},"http:\u002F\u002Fdev.mysql.com\u002Fdownloads\u002Frepo\u002Fyum\u002F",[1650],").\nIn this example I picked the following version.",[16,2447,2448,2452],{},[1646,2449,2450],{"href":2450,"rel":2451},"https:\u002F\u002Fdev.mysql.com\u002Fget\u002Fmysql57-community-release-el7-11.noarch.rpm",[1650],"\nNow let's download that version.",[47,2454,2456],{"className":49,"code":2455,"language":51,"meta":52,"style":52},"sudo rpm -Uvh https:\u002F\u002Fdev.mysql.com\u002Fget\u002Fmysql57-community-release-el7-11.noarch.rpm\n",[20,2457,2458],{"__ignoreMap":52},[56,2459,2460,2462,2465,2468],{"class":58,"line":59},[56,2461,2431],{"class":62},[56,2463,2464],{"class":66}," rpm",[56,2466,2467],{"class":66}," -Uvh",[56,2469,2470],{"class":66}," https:\u002F\u002Fdev.mysql.com\u002Fget\u002Fmysql57-community-release-el7-11.noarch.rpm\n",[16,2472,2473],{},"Once the download finishes, let's start the installation.",[47,2475,2477],{"className":49,"code":2476,"language":51,"meta":52,"style":52},"sudo yum install mysql-community-server\n",[20,2478,2479],{"__ignoreMap":52},[56,2480,2481,2483,2485,2488],{"class":58,"line":59},[56,2482,2431],{"class":62},[56,2484,2434],{"class":66},[56,2486,2487],{"class":66}," install",[56,2489,2490],{"class":66}," mysql-community-server\n",[16,2492,2493],{},"When the installation is done we can start MySQL Community Server.",[47,2495,2497],{"className":49,"code":2496,"language":51,"meta":52,"style":52},"sudo service mysqld start\n",[20,2498,2499],{"__ignoreMap":52},[56,2500,2501,2503,2506,2509],{"class":58,"line":59},[56,2502,2431],{"class":62},[56,2504,2505],{"class":66}," service",[56,2507,2508],{"class":66}," mysqld",[56,2510,2511],{"class":66}," start\n",[16,2513,2514],{},"We can check the server status with the following command.",[47,2516,2518],{"className":49,"code":2517,"language":51,"meta":52,"style":52},"sudo service mysqld status\n",[20,2519,2520],{"__ignoreMap":52},[56,2521,2522,2524,2526,2528],{"class":58,"line":59},[56,2523,2431],{"class":62},[56,2525,2505],{"class":66},[56,2527,2508],{"class":66},[56,2529,1079],{"class":66},[16,2531,2532],{},"If we see Active (running), we're successful.\nNow we should have questions in mind 🙂 I installed it, but what's my password, which port can I reach it on, etc.…",[16,2534,2535],{},"First let's set our password. A random password was generated during installation — let's grab it first.",[47,2537,2539],{"className":49,"code":2538,"language":51,"meta":52,"style":52},"sudo grep ‘temporary password’ \u002Fvar\u002Flog\u002Fmysqld.log\n",[20,2540,2541],{"__ignoreMap":52},[56,2542,2543,2545,2548,2551,2554],{"class":58,"line":59},[56,2544,2431],{"class":62},[56,2546,2547],{"class":66}," grep",[56,2549,2550],{"class":66}," ‘temporary",[56,2552,2553],{"class":66}," password’",[56,2555,2556],{"class":66}," \u002Fvar\u002Flog\u002Fmysqld.log\n",[16,2558,2559],{},"Great, we now have the random password. Let's change it — for that we need to connect to MySQL Server.",[47,2561,2563],{"className":49,"code":2562,"language":51,"meta":52,"style":52},"mysql -uroot -p\n",[20,2564,2565],{"__ignoreMap":52},[56,2566,2567,2570,2573],{"class":58,"line":59},[56,2568,2569],{"class":62},"mysql",[56,2571,2572],{"class":66}," -uroot",[56,2574,2575],{"class":66}," -p\n",[16,2577,2578],{},"We should land on the MySQL console — you'll see it as \"mysql>\". Let's change the password.",[47,2580,2582],{"className":49,"code":2581,"language":51,"meta":52,"style":52},"ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘YeniSifrem123!’;\n",[20,2583,2584],{"__ignoreMap":52},[56,2585,2586,2589,2592,2595,2598,2601,2604],{"class":58,"line":59},[56,2587,2588],{"class":62},"ALTER",[56,2590,2591],{"class":66}," USER",[56,2593,2594],{"class":66}," ‘root’@’localhost’",[56,2596,2597],{"class":66}," IDENTIFIED",[56,2599,2600],{"class":66}," BY",[56,2602,2603],{"class":66}," ‘YeniSifrem123!’",[56,2605,2606],{"class":76},";\n",[16,2608,2609],{},"Let's check the port too and finish up.",[47,2611,2613],{"className":49,"code":2612,"language":51,"meta":52,"style":52},"select @@port;\n",[20,2614,2615],{"__ignoreMap":52},[56,2616,2617,2621],{"class":58,"line":59},[56,2618,2620],{"class":2619},"s7zQu","select",[56,2622,2623],{"class":174}," @@port;\n",[16,2625,2626],{},"By the way, to exit the MySQL console type \"exit;\" and hit Enter — don't linger there 🙂",[1188,2628,2629],{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}",{"title":52,"searchDepth":86,"depth":86,"links":2631},[],"2017-09-27","Installing MySQL on CentOS 7 with yum and the initial configuration steps.",{},"\u002Fen\u002Fblog\u002Finstall-mysql-on-centos-7",{"title":2416,"description":2633},"en\u002Fblog\u002Finstall-mysql-on-centos-7",[2639,2569],"database management systems","\u002Fblog\u002Finstall-mysql-on-centos-7","V-imG0ImJ1DeVO-UJdyR_Xla7UeW-XP8PLScNocyMkk",{"id":2643,"title":2644,"body":2645,"date":2831,"description":2832,"extension":1203,"meta":2833,"navigation":231,"path":2834,"seo":2835,"stem":2836,"tags":2837,"translation":2839,"__hash__":2840},"pages_en\u002Fen\u002Fblog\u002Foracle-create-user-and-grant-privileges.md","Creating a User and Granting Privileges in Oracle",{"type":8,"value":2646,"toc":2829},[2647,2650,2677,2680,2701,2704,2722,2725,2743,2746,2766,2769,2826],[16,2648,2649],{},"Hello, the commands needed to create a user on Oracle DB can be as follows. I'm assuming we're connected with a privileged user. I've set the username as SUKRU.\nTo define the user:",[47,2651,2655],{"className":2652,"code":2653,"language":2654,"meta":52,"style":52},"language-sql shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","CREATE USER SUKRU IDENTIFIED BY SUKRU\n","sql",[20,2656,2657],{"__ignoreMap":52},[56,2658,2659,2662,2664,2668,2671,2674],{"class":58,"line":59},[56,2660,2661],{"class":999},"CREATE",[56,2663,2591],{"class":999},[56,2665,2667],{"class":2666},"s2Zo4"," SUKRU",[56,2669,2670],{"class":174}," IDENTIFIED ",[56,2672,2673],{"class":999},"BY",[56,2675,2676],{"class":174}," SUKRU\n",[16,2678,2679],{},"To grant the right to connect:",[47,2681,2683],{"className":2652,"code":2682,"language":2654,"meta":52,"style":52},"GRANT CREATE SESSION TO SUKRU\n",[20,2684,2685],{"__ignoreMap":52},[56,2686,2687,2690,2693,2696,2699],{"class":58,"line":59},[56,2688,2689],{"class":999},"GRANT",[56,2691,2692],{"class":999}," CREATE",[56,2694,2695],{"class":999}," SESSION",[56,2697,2698],{"class":999}," TO",[56,2700,2676],{"class":174},[16,2702,2703],{},"To grant the right to create tables:",[47,2705,2707],{"className":2652,"code":2706,"language":2654,"meta":52,"style":52},"GRANT CREATE TABLE TO SUKRU\n",[20,2708,2709],{"__ignoreMap":52},[56,2710,2711,2713,2715,2718,2720],{"class":58,"line":59},[56,2712,2689],{"class":999},[56,2714,2692],{"class":999},[56,2716,2717],{"class":999}," TABLE",[56,2719,2698],{"class":999},[56,2721,2676],{"class":174},[16,2723,2724],{},"To grant the right to create sequences:",[47,2726,2728],{"className":2652,"code":2727,"language":2654,"meta":52,"style":52},"GRANT CREATE SEQUENCE TO SUKRU\n",[20,2729,2730],{"__ignoreMap":52},[56,2731,2732,2734,2736,2739,2741],{"class":58,"line":59},[56,2733,2689],{"class":999},[56,2735,2692],{"class":999},[56,2737,2738],{"class":999}," SEQUENCE",[56,2740,2698],{"class":999},[56,2742,2676],{"class":174},[16,2744,2745],{},"To allow using tablespace:",[47,2747,2749],{"className":2652,"code":2748,"language":2654,"meta":52,"style":52},"GRANT UNLIMITED TABLESPACE TO SUKRU\n",[20,2750,2751],{"__ignoreMap":52},[56,2752,2753,2755,2758,2761,2764],{"class":58,"line":59},[56,2754,2689],{"class":999},[56,2756,2757],{"class":999}," UNLIMITED",[56,2759,2760],{"class":174}," TABLESPACE ",[56,2762,2763],{"class":999},"TO",[56,2765,2676],{"class":174},[16,2767,2768],{},"In current Oracle versions no privileges are needed for SELECT, INSERT, UPDATE, DELETE — but if required:",[47,2770,2772],{"className":2652,"code":2771,"language":2654,"meta":52,"style":52},"GRANT\n  SELECT,\n  INSERT,\n  UPDATE,\n  DELETE\nON\n  schema.table\nTO\n  SUKRU\n",[20,2773,2774,2779,2787,2794,2801,2806,2811,2816,2821],{"__ignoreMap":52},[56,2775,2776],{"class":58,"line":59},[56,2777,2778],{"class":999},"GRANT\n",[56,2780,2781,2784],{"class":58,"line":86},[56,2782,2783],{"class":999},"  SELECT",[56,2785,2786],{"class":174},",\n",[56,2788,2789,2792],{"class":58,"line":105},[56,2790,2791],{"class":999},"  INSERT",[56,2793,2786],{"class":174},[56,2795,2796,2799],{"class":58,"line":120},[56,2797,2798],{"class":999},"  UPDATE",[56,2800,2786],{"class":174},[56,2802,2803],{"class":58,"line":248},[56,2804,2805],{"class":999},"  DELETE\n",[56,2807,2808],{"class":58,"line":261},[56,2809,2810],{"class":999},"ON\n",[56,2812,2813],{"class":58,"line":274},[56,2814,2815],{"class":174},"  schema.table\n",[56,2817,2818],{"class":58,"line":279},[56,2819,2820],{"class":999},"TO\n",[56,2822,2823],{"class":58,"line":297},[56,2824,2825],{"class":174},"  SUKRU\n",[1188,2827,2828],{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":52,"searchDepth":86,"depth":86,"links":2830},[],"2017-08-08","Commands for creating a new user and granting privileges in Oracle.",{},"\u002Fen\u002Fblog\u002Foracle-create-user-and-grant-privileges",{"title":2644,"description":2832},"en\u002Fblog\u002Foracle-create-user-and-grant-privileges",[2838],"oracle","\u002Fblog\u002Foracle-create-user-and-grant-privileges","31-XGueqvMEFe2Rh7gIjJSln5213Q4-woBEOzZ--ISI",{"id":2842,"title":2843,"body":2844,"date":3037,"description":3038,"extension":1203,"meta":3039,"navigation":231,"path":3040,"seo":3041,"stem":3042,"tags":3043,"translation":3047,"__hash__":3048},"pages_en\u002Fen\u002Fblog\u002Fspring-security-primefaces-redirect-issue-fix.md","Fixing the Spring Security + PrimeFaces Redirect Issue",{"type":8,"value":2845,"toc":3035},[2846,2854,2871,2944,2947,2952,2958,2963,2969,2978,2981,2989,2992,3000,3003,3009,3012,3018,3032],[16,2847,2848,2849,1157],{},"Spring Security is a well-established name in the Java EE world and — in my opinion — a godsend for securing Java applications. You can find detailed info ",[1646,2850,2853],{"href":2851,"rel":2852},"http:\u002F\u002Fprojects.spring.io\u002Fspring-security\u002F",[1650],"on its site",[16,2855,2856,2857,2862,2863,2870],{},"PrimeFaces is also the most successful component library recognized in the JSF world; again, ",[1646,2858,2861],{"href":2859,"rel":2860},"http:\u002F\u002Fwww.primefaces.org",[1650],"detailed info is at this address",".\nIn my project built on JSF 2.2 + Spring 4 + Hibernate 4 + PrimeFaces 5, I noticed that after a successful login the page didn't navigate to the URL it was supposed to. When I examined the Spring Security logs, there was no problem at all — it was sending the request to the URL I specified in the configuration via \"",[1389,2864,2865],{},[1646,2866,2869],{"href":2867,"rel":2868},"https:\u002F\u002Ftomcat.apache.org\u002Ftomcat-5.5-doc\u002Fservletapi\u002Fjavax\u002Fservlet\u002Fhttp\u002FHttpServletResponse.html#sendRedirect(java.lang.String)",[1650],"sendRedirect","\". In a place where everything was this perfect, of course I went nuts trying to figure out how it could not work 🙂\nThe Spring Security log looks like this. It redirected from the \u002Flogin page to \u002Fpages\u002Fhome just as I wanted.",[47,2872,2874],{"className":49,"code":2873,"language":51,"meta":52,"style":52},"[DEBUG] ..access.intercept.FilterSecurityInterceptor – Authorization successful\n[DEBUG] ..security.web.FilterChainProxy            – \u002Fpages\u002Fhome.xhtml reached end of additional filter chain; proceeding with original chain\n[DEBUG] ..web.access.ExceptionTranslationFilter    – Chain processed normally\n[DEBUG] ..web.context.SecurityContextPersistenceFilter – SecurityContextHolder now cleared, as request processing completed\n",[20,2875,2876,2890,2922,2933],{"__ignoreMap":52},[56,2877,2878,2881,2884,2887],{"class":58,"line":59},[56,2879,2880],{"class":76},"[",[56,2882,2883],{"class":174},"DEBUG",[56,2885,2886],{"class":76},"]",[56,2888,2889],{"class":174}," ..access.intercept.FilterSecurityInterceptor – Authorization successful\n",[56,2891,2892,2894,2896,2898,2901,2904,2907,2910,2913,2916,2919],{"class":58,"line":86},[56,2893,2880],{"class":76},[56,2895,2883],{"class":174},[56,2897,2886],{"class":76},[56,2899,2900],{"class":174}," ..security.web.FilterChainProxy            – \u002Fpages\u002Fhome.xhtml reached ",[56,2902,2903],{"class":2619},"end",[56,2905,2906],{"class":174}," of additional filter chain",[56,2908,2909],{"class":76},";",[56,2911,2912],{"class":62}," proceeding",[56,2914,2915],{"class":66}," with",[56,2917,2918],{"class":66}," original",[56,2920,2921],{"class":66}," chain\n",[56,2923,2924,2926,2928,2930],{"class":58,"line":105},[56,2925,2880],{"class":76},[56,2927,2883],{"class":174},[56,2929,2886],{"class":76},[56,2931,2932],{"class":174}," ..web.access.ExceptionTranslationFilter    – Chain processed normally\n",[56,2934,2935,2937,2939,2941],{"class":58,"line":120},[56,2936,2880],{"class":76},[56,2938,2883],{"class":174},[56,2940,2886],{"class":76},[56,2942,2943],{"class":174}," ..web.context.SecurityContextPersistenceFilter – SecurityContextHolder now cleared, as request processing completed\n",[16,2945,2946],{},"I started digging deeper — first I watched the request\u002Fresponse flow in the browser.",[16,2948,2949],{},[1389,2950,2951],{},"Request:",[47,2953,2956],{"className":2954,"code":2955,"language":1226,"meta":52},[1224],"javax.faces.partial.ajax:true\njavax.faces.source:loginButton\njavax.faces.partial.execute:loginForm\njavax.faces.partial.render:loginForm\nloginButton:loginButton\nloginForm:loginForm\nusername:test\npassword:123456\n_csrf:49756ca7-38fd-4777-bea8-58fcfe7deb73\njavax.faces.ViewState:-3601270081246135757:6121484162719565648\n",[20,2957,2955],{"__ignoreMap":52},[16,2959,2960],{},[1389,2961,2962],{},"Response:",[47,2964,2967],{"className":2965,"code":2966,"language":1226,"meta":52},[1224],"xml version='1.0' encoding='UTF-8'?\n-6140875972550706628:-2367790204853062502\n",[20,2968,2966],{"__ignoreMap":52},[16,2970,2971,2972,2977],{},"When I saw these, of course ",[1646,2973,2976],{"href":2974,"rel":2975},"https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=gbnhydOczwI",[1650],"I said \"Oh my God\""," — why? 🙂",[16,2979,2980],{},"Because there's no \"redirect-url\" in the response! There's only an \"update\"! So we made a mistake in the Ajax part (javax.faces.partial.ajax:true), and there are two ways around it;",[1729,2982,2983,2986],{},[1124,2984,2985],{},"Setting ajax=\"false\" in the PrimeFaces commandButton attributes",[1124,2987,2988],{},"Using a classic JSF button instead of the PrimeFaces button",[16,2990,2991],{},"The button I was using",[47,2993,2996],{"className":2994,"code":52,"language":2995,"meta":52,"style":52},"language-xml shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","xml",[20,2997,2998],{"__ignoreMap":52},[56,2999],{"class":58,"line":59},[16,3001,3002],{},"Option 1",[47,3004,3005],{"className":2994,"code":52,"language":2995,"meta":52,"style":52},[20,3006,3007],{"__ignoreMap":52},[56,3008],{"class":58,"line":59},[16,3010,3011],{},"Option 2 (you can't benefit from the PrimeFaces button's CSS here — you'd have to add it manually)",[47,3013,3014],{"className":2994,"code":52,"language":2995,"meta":52,"style":52},[20,3015,3016],{"__ignoreMap":52},[56,3017],{"class":58,"line":59},[16,3019,3020,3021,3026,3027],{},"In the end it looks this simple, but I couldn't figure it out without watching the traffic in the browser. By the way, it's become nearly standard in all browsers — it's usually called \"Developer Tools\" and you can open it with F12; I wanted to mention it in case some don't know.\nBesides these, we could have done this by overriding the place where Spring Security calls \"sendRedirect\", but that would be more costly. How to do it was given in ",[1646,3022,3025],{"href":3023,"rel":3024},"http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F9305144\u002Fusing-jsf-2-0-facelets-is-there-a-way-to-attach-a-global-listener-to-all-ajax\u002F9311920#9311920",[1650],"this answer"," by the master BalusC 🙂\nFor the root of the problem, ",[1646,3028,3031],{"href":3029,"rel":3030},"http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002F10954319\u002Fjsf-2-response-sendredirect-is-not-working",[1650],"see this resource.",[1188,3033,3034],{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":52,"searchDepth":86,"depth":86,"links":3036},[],"2015-05-15","The fix for the redirect problem that appears when using Spring Security with PrimeFaces.",{},"\u002Fen\u002Fblog\u002Fspring-security-primefaces-redirect-issue-fix",{"title":2843,"description":3038},"en\u002Fblog\u002Fspring-security-primefaces-redirect-issue-fix",[1758,3044,3045,3046],"jsf","primefaces","spring","\u002Fblog\u002Fspring-security-primefaces-redirect-issue-fix","PgYxzMV0jD2UoMI45dVjfY-PRcUUSADD7TE6TzCVNTg",{"id":3050,"title":3051,"body":3052,"date":3162,"description":3163,"extension":1203,"meta":3164,"navigation":231,"path":3165,"seo":3166,"stem":3167,"tags":3168,"translation":3169,"__hash__":3170},"pages_en\u002Fen\u002Fblog\u002Fjsf-2-primefaces.md","JSF 2 + PrimeFaces",{"type":8,"value":3053,"toc":3160},[3054,3072,3077,3080,3103,3106,3111,3114,3128,3134,3139,3150,3157],[16,3055,3056,3060,3061,3066,3067,1157],{},[1646,3057,3059],{"href":2859,"rel":3058},[1650],"PrimeFaces"," is the leading component library written for JSF 2. As of now it's also the only component library bundled with the ",[1646,3062,3065],{"href":3063,"rel":3064},"http:\u002F\u002Fwww.netbeans.org",[1650],"NetBeans"," IDE. You can find many of its advanced components and details on the ",[1646,3068,3071],{"href":3069,"rel":3070},"http:\u002F\u002Fwww.primefaces.org\u002Fshowcase\u002F",[1650],"showcase pages",[16,3073,3074],{},[1389,3075,3076],{},"Before starting this post…",[16,3078,3079],{},"I recommend reading the following posts I wrote earlier before diving into this article.",[1729,3081,3082,3089,3096],{},[1124,3083,3084],{},[1646,3085,3088],{"href":3086,"rel":3087},"https:\u002F\u002Fwww.sukrucakmak.com\u002Fjsf-life-cycle\u002F",[1650],"JSF Life Cycle",[1124,3090,3091],{},[1646,3092,3095],{"href":3093,"rel":3094},"https:\u002F\u002Fwww.sukrucakmak.com\u002Fjsf-model-view-controller-mvc\u002F",[1650],"JSF Model-View-Controller",[1124,3097,3098],{},[1646,3099,3102],{"href":3100,"rel":3101},"https:\u002F\u002Fwww.sukrucakmak.com\u002Fjavaserver-faces-2-jsf-2\u002F",[1650],"Introduction to JSF 2",[16,3104,3105],{},"If you already know these topics you don't need to read them, but since I'll continue this post on the development environment we set up in the JSF 2 introduction, it's worth at least taking a look at that one.",[16,3107,3108],{},[1389,3109,3110],{},"Powering Up with PrimeFaces",[16,3112,3113],{},"Powering up our JSF 2 project with PrimeFaces takes only two steps.",[1729,3115,3116,3125],{},[1124,3117,3118,3119,3124],{},"Download the latest stable release from the PrimeFaces ",[1646,3120,3123],{"href":3121,"rel":3122},"http:\u002F\u002Fwww.primefaces.org\u002Fdownloads.html",[1650],"download page"," and add it to the project's libraries.",[1124,3126,3127],{},"Add the following line to the xmlns declarations at the top of your xhtml pages.",[47,3129,3132],{"className":3130,"code":3131,"language":1226},[1224],"xmlns:p=\"http:\u002F\u002Fprimefaces.org\u002Fui\"\n",[20,3133,3131],{"__ignoreMap":52},[16,3135,3136],{},[2168,3137],{"alt":52,"src":3138},"\u002Fimages\u002Fjsf-2-primefaces-Screen-Shot-2011-09-06-at-11.50.52-PM.png",[16,3140,3141,3142,3145,3146,3149],{},"Yes, that's all! From now on we can use PrimeFaces components inside our pages.\nAs you can see, we've added the component inside the ",[1389,3143,3144],{},"index.xhtml"," page. When we run the project and open the ",[1389,3147,3148],{},"index.jsf"," page we get something like the following.",[16,3151,3152],{},[1646,3153,3155],{"href":3154},"\u002Fimages\u002Fjsf-2-primefaces-Screen-Shot-2011-09-03-at-2.12.37-PM.png",[2168,3156],{"alt":52,"src":3154},[16,3158,3159],{},"In the next post we'll enhance this JSF 2 + PrimeFaces application using Ajax.\nTake it easy.",{"title":52,"searchDepth":86,"depth":86,"links":3161},[],"2011-09-05","Building rich user interfaces on JSF 2 with the PrimeFaces component library.",{},"\u002Fen\u002Fblog\u002Fjsf-2-primefaces",{"title":3051,"description":3163},"en\u002Fblog\u002Fjsf-2-primefaces",[1758,3044],"\u002Fblog\u002Fjsf-2-primefaces","fvrxBTtbpKNP9_mqjXVETjsQJhvpOqQT1eCh-bGiRCE",{"id":3172,"title":3173,"body":3174,"date":3991,"description":3992,"extension":1203,"meta":3993,"navigation":231,"path":3994,"seo":3995,"stem":3996,"tags":3997,"translation":3998,"__hash__":3999},"pages_en\u002Fen\u002Fblog\u002Fjavaserver-faces-2-jsf-2.md","JavaServer Faces 2 (JSF 2)",{"type":8,"value":3175,"toc":3989},[3176,3189,3211,3216,3228,3233,3251,3256,3268,3273,3276,3419,3422,3756,3761,3764,3952,3957,3986],[16,3177,3178,3179,3183,3184,3188],{},"JavaServer Faces (JSF) has been accepted by the Java Committee as the standard web technology. Anyone who wants to do web programming with Java is recommended to learn it. You can find detailed info at ",[1646,3180,3181],{"href":3181,"rel":3182},"http:\u002F\u002Fjavaserverfaces.java.net\u002F",[1650],".\nSince JSF is based on Model-View-Controller (MVC), our Java classes and our visual pages — the front end — live in separate layers. I explained this topic in detail ",[1646,3185,3187],{"href":3093,"rel":3186},[1650],"on this page",".\nNow let's build our first application with JSF 2. We need the following ingredients — or rather, these are the ones I'll be using;",[1121,3190,3191,3198,3205],{},[1124,3192,3193],{},[1646,3194,3197],{"href":3195,"rel":3196},"http:\u002F\u002Fwww.eclipse.org\u002Fdownloads\u002F",[1650],"Eclipse Java EE IDE for Web Developers (Helios)",[1124,3199,3200],{},[1646,3201,3204],{"href":3202,"rel":3203},"http:\u002F\u002Ftomcat.apache.org\u002Fdownload-70.cgi",[1650],"Apache Tomcat 7",[1124,3206,3207],{},[1646,3208,3210],{"href":3181,"rel":3209},[1650],"JSF 2 Libraries (jsf-api.jar and jsf-impl.jar)",[16,3212,3213],{},[1389,3214,3215],{},"Tomcat",[16,3217,3218,3219,3222,3223],{},"Let's start Eclipse and open a new workspace. First let's register the \"Server\". After right-clicking in the Server tab and following ",[1389,3220,3221],{},"New > Server",", you can point at Tomcat's location as shown below.\n",[1646,3224,3226],{"href":3225},"\u002Fimages\u002Fjavaserver-faces-2-jsf-2-Screen-Shot-2011-09-02-at-12.55.44-PM.png",[2168,3227],{"alt":52,"src":3225},[16,3229,3230],{},[1389,3231,3232],{},"Creating the Project",[16,3234,3235,3236,3239,3240,3245,3246],{},"Now in the \"Package Explorer\" or \"Project Explorer\" view, we create the project via ",[1389,3237,3238],{},"New > Dynamic Web Project"," as shown below. First we fill in fields like the project name.\n",[1646,3241,3243],{"href":3242},"\u002Fimages\u002Fjavaserver-faces-2-jsf-2-Screen-Shot-2011-09-02-at-1.00.59-PM.png",[2168,3244],{"alt":52,"src":3242},"\nThen by clicking Next and Next again we make it generate the \"web.xml\" file as shown below, and hit the \"finish\" button.\n",[1646,3247,3249],{"href":3248},"\u002Fimages\u002Fjavaserver-faces-2-jsf-2-Screen-Shot-2011-09-02-at-2.53.42-PM.png",[2168,3250],{"alt":52,"src":3248},[16,3252,3253],{},[1389,3254,3255],{},"Required Jars for JSF 2",[16,3257,3258,3259,3262,3263],{},"There are a few steps we need to take for our JSF 2 application to run; first, let's copy the 2 jar files we mentioned at the beginning into the ",[1389,3260,3261],{},"WEB-INF\u002Flib"," directory — our project should look like the one below.\n",[1646,3264,3266],{"href":3265},"\u002Fimages\u002Fjavaserver-faces-2-jsf-2-Screen-Shot-2011-09-06-at-11.43.46-PM.png",[2168,3267],{"alt":52,"src":3265},[16,3269,3270],{},[1389,3271,3272],{},"web.xml Settings",[16,3274,3275],{},"For our JSF 2 application to be interpreted by the server we need to add the following lines into web.xml.",[47,3277,3279],{"className":2994,"code":3278,"language":2995,"meta":52,"style":52},"        \u003C!– Faces Servlet –>\n    \u003Cservlet>\n        \u003Cservlet-name>Faces Servlet\u003C\u002Fservlet-name>\n        \u003Cservlet-class>javax.faces.webapp.FacesServlet\u003C\u002Fservlet-class>\n        \u003Cload-on-startup> 1 \u003C\u002Fload-on-startup>\n    \u003C\u002Fservlet>\n    \u003C!– Faces Servlet Mapping –>\n    \u003Cservlet-mapping>\n        \u003Cservlet-name>Faces Servlet\u003C\u002Fservlet-name>\n        \u003Curl-pattern>*.jsf\u003C\u002Furl-pattern>\n    \u003C\u002Fservlet-mapping>\n",[20,3280,3281,3286,3298,3318,3336,3354,3363,3368,3377,3393,3411],{"__ignoreMap":52},[56,3282,3283],{"class":58,"line":59},[56,3284,3285],{"class":174},"        \u003C!– Faces Servlet –>\n",[56,3287,3288,3291,3295],{"class":58,"line":86},[56,3289,3290],{"class":76},"    \u003C",[56,3292,3294],{"class":3293},"swJcz","servlet",[56,3296,3297],{"class":76},">\n",[56,3299,3300,3303,3306,3308,3311,3314,3316],{"class":58,"line":105},[56,3301,3302],{"class":76},"        \u003C",[56,3304,3305],{"class":3293},"servlet-name",[56,3307,178],{"class":76},[56,3309,3310],{"class":174},"Faces Servlet",[56,3312,3313],{"class":76},"\u003C\u002F",[56,3315,3305],{"class":3293},[56,3317,3297],{"class":76},[56,3319,3320,3322,3325,3327,3330,3332,3334],{"class":58,"line":120},[56,3321,3302],{"class":76},[56,3323,3324],{"class":3293},"servlet-class",[56,3326,178],{"class":76},[56,3328,3329],{"class":174},"javax.faces.webapp.FacesServlet",[56,3331,3313],{"class":76},[56,3333,3324],{"class":3293},[56,3335,3297],{"class":76},[56,3337,3338,3340,3343,3345,3348,3350,3352],{"class":58,"line":248},[56,3339,3302],{"class":76},[56,3341,3342],{"class":3293},"load-on-startup",[56,3344,178],{"class":76},[56,3346,3347],{"class":174}," 1 ",[56,3349,3313],{"class":76},[56,3351,3342],{"class":3293},[56,3353,3297],{"class":76},[56,3355,3356,3359,3361],{"class":58,"line":261},[56,3357,3358],{"class":76},"    \u003C\u002F",[56,3360,3294],{"class":3293},[56,3362,3297],{"class":76},[56,3364,3365],{"class":58,"line":274},[56,3366,3367],{"class":174},"    \u003C!– Faces Servlet Mapping –>\n",[56,3369,3370,3372,3375],{"class":58,"line":279},[56,3371,3290],{"class":76},[56,3373,3374],{"class":3293},"servlet-mapping",[56,3376,3297],{"class":76},[56,3378,3379,3381,3383,3385,3387,3389,3391],{"class":58,"line":297},[56,3380,3302],{"class":76},[56,3382,3305],{"class":3293},[56,3384,178],{"class":76},[56,3386,3310],{"class":174},[56,3388,3313],{"class":76},[56,3390,3305],{"class":3293},[56,3392,3297],{"class":76},[56,3394,3395,3397,3400,3402,3405,3407,3409],{"class":58,"line":318},[56,3396,3302],{"class":76},[56,3398,3399],{"class":3293},"url-pattern",[56,3401,178],{"class":76},[56,3403,3404],{"class":174},"*.jsf",[56,3406,3313],{"class":76},[56,3408,3399],{"class":3293},[56,3410,3297],{"class":76},[56,3412,3413,3415,3417],{"class":58,"line":813},[56,3414,3358],{"class":76},[56,3416,3374],{"class":3293},[56,3418,3297],{"class":76},[16,3420,3421],{},"After adding these lines, web.xml will look like the one below.",[47,3423,3425],{"className":2994,"code":3424,"language":2995,"meta":52,"style":52},"\u003C?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\u003Cweb-app xmlns:xsi=\"http:\u002F\u002Fwww.w3.org\u002F2001\u002FXMLSchema-instance\"\n    xmlns=\"http:\u002F\u002Fjava.sun.com\u002Fxml\u002Fns\u002Fjavaee\" xmlns:web=\"http:\u002F\u002Fjava.sun.com\u002Fxml\u002Fns\u002Fjavaee\u002Fweb-app_2_5.xsd\"\n    xsi:schemaLocation=\"http:\u002F\u002Fjava.sun.com\u002Fxml\u002Fns\u002Fjavaee http:\u002F\u002Fjava.sun.com\u002Fxml\u002Fns\u002Fjavaee\u002Fweb-app_2_5.xsd\"\n    id=\"WebApp_ID\" version=\"2.5\">\n    \u003Cdisplay-name>jsf2-helloworld\u003C\u002Fdisplay-name>\n    \u003C!– Faces Servlet –>\n    \u003Cservlet>\n        \u003Cservlet-name>Faces Servlet\u003C\u002Fservlet-name>\n        \u003Cservlet-class>javax.faces.webapp.FacesServlet\u003C\u002Fservlet-class>\n        \u003Cload-on-startup> 1 \u003C\u002Fload-on-startup>\n    \u003C\u002Fservlet>\n    \u003C!– Faces Servlet Mapping –>\n    \u003Cservlet-mapping>\n        \u003Cservlet-name>Faces Servlet\u003C\u002Fservlet-name>\n        \u003Curl-pattern>*.jsf\u003C\u002Furl-pattern>\n    \u003C\u002Fservlet-mapping>\n    \u003Cwelcome-file-list>\n        \u003Cwelcome-file>index.html\u003C\u002Fwelcome-file>\n    \u003C\u002Fwelcome-file-list>\n\u003C\u002Fweb-app>\n",[20,3426,3427,3463,3489,3519,3538,3565,3583,3588,3596,3612,3628,3644,3652,3657,3666,3683,3700,3709,3719,3738,3747],{"__ignoreMap":52},[56,3428,3429,3432,3434,3438,3441,3443,3446,3448,3451,3453,3455,3458,3460],{"class":58,"line":59},[56,3430,3431],{"class":76},"\u003C?",[56,3433,2995],{"class":3293},[56,3435,3437],{"class":3436},"spNyl"," version",[56,3439,3440],{"class":76},"=",[56,3442,312],{"class":76},[56,3444,3445],{"class":66},"1.0",[56,3447,312],{"class":76},[56,3449,3450],{"class":3436}," encoding",[56,3452,3440],{"class":76},[56,3454,312],{"class":76},[56,3456,3457],{"class":66},"UTF-8",[56,3459,312],{"class":76},[56,3461,3462],{"class":76},"?>\n",[56,3464,3465,3468,3471,3474,3477,3480,3482,3484,3487],{"class":58,"line":86},[56,3466,3467],{"class":76},"\u003C",[56,3469,3470],{"class":3293},"web-app",[56,3472,3473],{"class":3436}," xmlns",[56,3475,3476],{"class":76},":",[56,3478,3479],{"class":3436},"xsi",[56,3481,3440],{"class":76},[56,3483,312],{"class":76},[56,3485,3486],{"class":66},"http:\u002F\u002Fwww.w3.org\u002F2001\u002FXMLSchema-instance",[56,3488,83],{"class":76},[56,3490,3491,3494,3496,3498,3501,3503,3505,3507,3510,3512,3514,3517],{"class":58,"line":105},[56,3492,3493],{"class":3436},"    xmlns",[56,3495,3440],{"class":76},[56,3497,312],{"class":76},[56,3499,3500],{"class":66},"http:\u002F\u002Fjava.sun.com\u002Fxml\u002Fns\u002Fjavaee",[56,3502,312],{"class":76},[56,3504,3473],{"class":3436},[56,3506,3476],{"class":76},[56,3508,3509],{"class":3436},"web",[56,3511,3440],{"class":76},[56,3513,312],{"class":76},[56,3515,3516],{"class":66},"http:\u002F\u002Fjava.sun.com\u002Fxml\u002Fns\u002Fjavaee\u002Fweb-app_2_5.xsd",[56,3518,83],{"class":76},[56,3520,3521,3524,3526,3529,3531,3533,3536],{"class":58,"line":120},[56,3522,3523],{"class":3436},"    xsi",[56,3525,3476],{"class":76},[56,3527,3528],{"class":3436},"schemaLocation",[56,3530,3440],{"class":76},[56,3532,312],{"class":76},[56,3534,3535],{"class":66},"http:\u002F\u002Fjava.sun.com\u002Fxml\u002Fns\u002Fjavaee http:\u002F\u002Fjava.sun.com\u002Fxml\u002Fns\u002Fjavaee\u002Fweb-app_2_5.xsd",[56,3537,83],{"class":76},[56,3539,3540,3543,3545,3547,3550,3552,3554,3556,3558,3561,3563],{"class":58,"line":248},[56,3541,3542],{"class":3436},"    id",[56,3544,3440],{"class":76},[56,3546,312],{"class":76},[56,3548,3549],{"class":66},"WebApp_ID",[56,3551,312],{"class":76},[56,3553,3437],{"class":3436},[56,3555,3440],{"class":76},[56,3557,312],{"class":76},[56,3559,3560],{"class":66},"2.5",[56,3562,312],{"class":76},[56,3564,3297],{"class":76},[56,3566,3567,3569,3572,3574,3577,3579,3581],{"class":58,"line":261},[56,3568,3290],{"class":76},[56,3570,3571],{"class":3293},"display-name",[56,3573,178],{"class":76},[56,3575,3576],{"class":174},"jsf2-helloworld",[56,3578,3313],{"class":76},[56,3580,3571],{"class":3293},[56,3582,3297],{"class":76},[56,3584,3585],{"class":58,"line":274},[56,3586,3587],{"class":174},"    \u003C!– Faces Servlet –>\n",[56,3589,3590,3592,3594],{"class":58,"line":279},[56,3591,3290],{"class":76},[56,3593,3294],{"class":3293},[56,3595,3297],{"class":76},[56,3597,3598,3600,3602,3604,3606,3608,3610],{"class":58,"line":297},[56,3599,3302],{"class":76},[56,3601,3305],{"class":3293},[56,3603,178],{"class":76},[56,3605,3310],{"class":174},[56,3607,3313],{"class":76},[56,3609,3305],{"class":3293},[56,3611,3297],{"class":76},[56,3613,3614,3616,3618,3620,3622,3624,3626],{"class":58,"line":318},[56,3615,3302],{"class":76},[56,3617,3324],{"class":3293},[56,3619,178],{"class":76},[56,3621,3329],{"class":174},[56,3623,3313],{"class":76},[56,3625,3324],{"class":3293},[56,3627,3297],{"class":76},[56,3629,3630,3632,3634,3636,3638,3640,3642],{"class":58,"line":813},[56,3631,3302],{"class":76},[56,3633,3342],{"class":3293},[56,3635,178],{"class":76},[56,3637,3347],{"class":174},[56,3639,3313],{"class":76},[56,3641,3342],{"class":3293},[56,3643,3297],{"class":76},[56,3645,3646,3648,3650],{"class":58,"line":1913},[56,3647,3358],{"class":76},[56,3649,3294],{"class":3293},[56,3651,3297],{"class":76},[56,3653,3655],{"class":58,"line":3654},13,[56,3656,3367],{"class":174},[56,3658,3660,3662,3664],{"class":58,"line":3659},14,[56,3661,3290],{"class":76},[56,3663,3374],{"class":3293},[56,3665,3297],{"class":76},[56,3667,3669,3671,3673,3675,3677,3679,3681],{"class":58,"line":3668},15,[56,3670,3302],{"class":76},[56,3672,3305],{"class":3293},[56,3674,178],{"class":76},[56,3676,3310],{"class":174},[56,3678,3313],{"class":76},[56,3680,3305],{"class":3293},[56,3682,3297],{"class":76},[56,3684,3686,3688,3690,3692,3694,3696,3698],{"class":58,"line":3685},16,[56,3687,3302],{"class":76},[56,3689,3399],{"class":3293},[56,3691,178],{"class":76},[56,3693,3404],{"class":174},[56,3695,3313],{"class":76},[56,3697,3399],{"class":3293},[56,3699,3297],{"class":76},[56,3701,3703,3705,3707],{"class":58,"line":3702},17,[56,3704,3358],{"class":76},[56,3706,3374],{"class":3293},[56,3708,3297],{"class":76},[56,3710,3712,3714,3717],{"class":58,"line":3711},18,[56,3713,3290],{"class":76},[56,3715,3716],{"class":3293},"welcome-file-list",[56,3718,3297],{"class":76},[56,3720,3722,3724,3727,3729,3732,3734,3736],{"class":58,"line":3721},19,[56,3723,3302],{"class":76},[56,3725,3726],{"class":3293},"welcome-file",[56,3728,178],{"class":76},[56,3730,3731],{"class":174},"index.html",[56,3733,3313],{"class":76},[56,3735,3726],{"class":3293},[56,3737,3297],{"class":76},[56,3739,3741,3743,3745],{"class":58,"line":3740},20,[56,3742,3358],{"class":76},[56,3744,3716],{"class":3293},[56,3746,3297],{"class":76},[56,3748,3750,3752,3754],{"class":58,"line":3749},21,[56,3751,3313],{"class":76},[56,3753,3470],{"class":3293},[56,3755,3297],{"class":76},[16,3757,3758],{},[1389,3759,3760],{},"Creating an xhtml Page",[16,3762,3763],{},"Now all our infrastructure preparations are done — time to create a page and run it. We create a file named index.xhtml under the WebContent directory and edit it as below.",[47,3765,3769],{"className":3766,"code":3767,"language":3768,"meta":52,"style":52},"language-html shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u003C!DOCTYPE html PUBLIC \"-\u002F\u002FW3C\u002F\u002FDTD XHTML 1.0 Transitional\u002F\u002FEN\" \"http:\u002F\u002Fwww.w3.org\u002FTR\u002Fxhtml1\u002FDTD\u002Fxhtml1-transitional.dtd\">\n\u003Chtml xmlns=\"http:\u002F\u002Fwww.w3.org\u002F1999\u002Fxhtml\"\n    xmlns:h=\"http:\u002F\u002Fjava.sun.com\u002Fjsf\u002Fhtml\"\n    xmlns:f=\"http:\u002F\u002Fjava.sun.com\u002Fjsf\u002Fcore\"\n    xmlns:ui=\"http:\u002F\u002Fjava.sun.com\u002Fjsf\u002Ffacelets\">\n\u003Ch:head>\n    \u003Cmeta http-equiv=\"Content-Type\" content=\"text\u002Fhtml; charset=UTF-8\" \u002F>\n    \u003Ctitle>jsf2-helloworld\u003C\u002Ftitle>\n\u003C\u002Fh:head>\n\u003Ch:body>\n    Merhaba JSF 2\n\u003C\u002Fh:body>\n\u003C\u002Fhtml>\n","html",[20,3770,3771,3793,3810,3824,3838,3854,3863,3897,3914,3922,3931,3936,3944],{"__ignoreMap":52},[56,3772,3773,3776,3779,3782,3785,3788,3791],{"class":58,"line":59},[56,3774,3775],{"class":76},"\u003C!",[56,3777,3778],{"class":3293},"DOCTYPE",[56,3780,3781],{"class":3436}," html",[56,3783,3784],{"class":3436}," PUBLIC",[56,3786,3787],{"class":66}," \"-\u002F\u002FW3C\u002F\u002FDTD XHTML 1.0 Transitional\u002F\u002FEN\"",[56,3789,3790],{"class":66}," \"http:\u002F\u002Fwww.w3.org\u002FTR\u002Fxhtml1\u002FDTD\u002Fxhtml1-transitional.dtd\"",[56,3792,3297],{"class":76},[56,3794,3795,3797,3799,3801,3803,3805,3808],{"class":58,"line":86},[56,3796,3467],{"class":76},[56,3798,3768],{"class":3293},[56,3800,3473],{"class":3436},[56,3802,3440],{"class":76},[56,3804,312],{"class":76},[56,3806,3807],{"class":66},"http:\u002F\u002Fwww.w3.org\u002F1999\u002Fxhtml",[56,3809,83],{"class":76},[56,3811,3812,3815,3817,3819,3822],{"class":58,"line":105},[56,3813,3814],{"class":3436},"    xmlns:h",[56,3816,3440],{"class":76},[56,3818,312],{"class":76},[56,3820,3821],{"class":66},"http:\u002F\u002Fjava.sun.com\u002Fjsf\u002Fhtml",[56,3823,83],{"class":76},[56,3825,3826,3829,3831,3833,3836],{"class":58,"line":120},[56,3827,3828],{"class":3436},"    xmlns:f",[56,3830,3440],{"class":76},[56,3832,312],{"class":76},[56,3834,3835],{"class":66},"http:\u002F\u002Fjava.sun.com\u002Fjsf\u002Fcore",[56,3837,83],{"class":76},[56,3839,3840,3843,3845,3847,3850,3852],{"class":58,"line":248},[56,3841,3842],{"class":3436},"    xmlns:ui",[56,3844,3440],{"class":76},[56,3846,312],{"class":76},[56,3848,3849],{"class":66},"http:\u002F\u002Fjava.sun.com\u002Fjsf\u002Ffacelets",[56,3851,312],{"class":76},[56,3853,3297],{"class":76},[56,3855,3856,3858,3861],{"class":58,"line":261},[56,3857,3467],{"class":76},[56,3859,3860],{"class":3293},"h:head",[56,3862,3297],{"class":76},[56,3864,3865,3867,3870,3873,3875,3877,3880,3882,3885,3887,3889,3892,3894],{"class":58,"line":274},[56,3866,3290],{"class":76},[56,3868,3869],{"class":3293},"meta",[56,3871,3872],{"class":3436}," http-equiv",[56,3874,3440],{"class":76},[56,3876,312],{"class":76},[56,3878,3879],{"class":66},"Content-Type",[56,3881,312],{"class":76},[56,3883,3884],{"class":3436}," content",[56,3886,3440],{"class":76},[56,3888,312],{"class":76},[56,3890,3891],{"class":66},"text\u002Fhtml; charset=UTF-8",[56,3893,312],{"class":76},[56,3895,3896],{"class":76}," \u002F>\n",[56,3898,3899,3901,3904,3906,3908,3910,3912],{"class":58,"line":279},[56,3900,3290],{"class":76},[56,3902,3903],{"class":3293},"title",[56,3905,178],{"class":76},[56,3907,3576],{"class":174},[56,3909,3313],{"class":76},[56,3911,3903],{"class":3293},[56,3913,3297],{"class":76},[56,3915,3916,3918,3920],{"class":58,"line":297},[56,3917,3313],{"class":76},[56,3919,3860],{"class":3293},[56,3921,3297],{"class":76},[56,3923,3924,3926,3929],{"class":58,"line":318},[56,3925,3467],{"class":76},[56,3927,3928],{"class":3293},"h:body",[56,3930,3297],{"class":76},[56,3932,3933],{"class":58,"line":813},[56,3934,3935],{"class":174},"    Merhaba JSF 2\n",[56,3937,3938,3940,3942],{"class":58,"line":1913},[56,3939,3313],{"class":76},[56,3941,3928],{"class":3293},[56,3943,3297],{"class":76},[56,3945,3946,3948,3950],{"class":58,"line":3654},[56,3947,3313],{"class":76},[56,3949,3768],{"class":3293},[56,3951,3297],{"class":76},[16,3953,3954],{},[1389,3955,3956],{},"Running the Project",[16,3958,3959,3960,3963,3964,3969,3970,3974,3975,3980,3981,3985],{},"We add our project under Tomcat via ",[1389,3961,3962],{},"Add and Remove"," in Tomcat's menu.\n",[1646,3965,3967],{"href":3966},"\u002Fimages\u002Fjavaserver-faces-2-jsf-2-Screen-Shot-2011-09-02-at-3.37.24-PM.png",[2168,3968],{"alt":52,"src":3966},"\nThen we start Tomcat. If you haven't made any port changes, going to ",[1646,3971,3972],{"href":3972,"rel":3973},"http:\u002F\u002Flocalhost:8080\u002Fjsf2-helloworld\u002Findex.jsf",[1650]," shows us the screen below.\n",[1646,3976,3978],{"href":3977},"\u002Fimages\u002Fjavaserver-faces-2-jsf-2-Screen-Shot-2011-09-02-at-3.42.01-PM.png",[2168,3979],{"alt":52,"src":3977},"\nWe now have a JSF 2 application in its purest form. In the next lesson we'll add the ",[1646,3982,3059],{"href":3983,"rel":3984},"http:\u002F\u002Fwww.primefaces.org\u002F",[1650]," component suite to this application. We'll enrich the application beyond its plain form with the components PrimeFaces provides.\nTake it easy.",[1188,3987,3988],{},"html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":52,"searchDepth":86,"depth":86,"links":3990},[],"2011-09-02","An introduction to JavaServer Faces 2: the fundamentals of component-based web development.",{},"\u002Fen\u002Fblog\u002Fjavaserver-faces-2-jsf-2",{"title":3173,"description":3992},"en\u002Fblog\u002Fjavaserver-faces-2-jsf-2",[1758,3044],"\u002Fblog\u002Fjavaserver-faces-2-jsf-2","IrghK5ei-T-IaGtRCXkD0ak_MqajcIeEJ_9PmzL35FA",{"id":4001,"title":4002,"body":4003,"date":5648,"description":5649,"extension":1203,"meta":5650,"navigation":231,"path":5651,"seo":5652,"stem":5653,"tags":5654,"translation":5655,"__hash__":5656},"pages_en\u002Fen\u002Fblog\u002Fparse-xml-list-into-objects.md","Parsing an XML List into Objects",{"type":8,"value":4004,"toc":5646},[4005,4014,4125,4137,4673,4676,4961,4964,4967,4992,4995,5018,5034,5051,5054,5631,5634,5640,5643],[16,4006,4007,4008,4013],{},"I mentioned the XStream library in ",[1646,4009,4012],{"href":4010,"rel":4011},"https:\u002F\u002Fwww.sukrucakmak.com\u002Fxstream-java-to-xml-xml-to-java\u002F",[1650],"this post",". It helps us convert Java to XML and XML to Java. However, I realized I skipped a topic: what if instead of an object we have objects — what will the output look like then? If there's a bunch of objects as a list in the XML, how do we convert them to Java? In this post I'll try to shed light on these topics, but reading the first post is a must since I'll use the \"Ders\" and \"Ogretmen\" classes from there.\nGenerating the XML output of a single \"Ders\" object was very easy and produced a result like the one below.",[47,4015,4017],{"className":2994,"code":4016,"language":2995,"meta":52,"style":52},"\u003CDers>\n  \u003Cid>1\u003C\u002Fid>\n  \u003Cad>Software Engineering\u003C\u002Fad>\n  \u003Cogretmen>\n    \u003Cad>Yasin\u003C\u002Fad>\n    \u003Csoyad>Kenar\u003C\u002Fsoyad>\n  \u003C\u002Fogretmen>\n\u003C\u002FDers>\n",[20,4018,4019,4028,4046,4064,4073,4090,4108,4117],{"__ignoreMap":52},[56,4020,4021,4023,4026],{"class":58,"line":59},[56,4022,3467],{"class":76},[56,4024,4025],{"class":3293},"Ders",[56,4027,3297],{"class":76},[56,4029,4030,4033,4036,4038,4040,4042,4044],{"class":58,"line":86},[56,4031,4032],{"class":76},"  \u003C",[56,4034,4035],{"class":3293},"id",[56,4037,178],{"class":76},[56,4039,1000],{"class":174},[56,4041,3313],{"class":76},[56,4043,4035],{"class":3293},[56,4045,3297],{"class":76},[56,4047,4048,4050,4053,4055,4058,4060,4062],{"class":58,"line":105},[56,4049,4032],{"class":76},[56,4051,4052],{"class":3293},"ad",[56,4054,178],{"class":76},[56,4056,4057],{"class":174},"Software Engineering",[56,4059,3313],{"class":76},[56,4061,4052],{"class":3293},[56,4063,3297],{"class":76},[56,4065,4066,4068,4071],{"class":58,"line":120},[56,4067,4032],{"class":76},[56,4069,4070],{"class":3293},"ogretmen",[56,4072,3297],{"class":76},[56,4074,4075,4077,4079,4081,4084,4086,4088],{"class":58,"line":248},[56,4076,3290],{"class":76},[56,4078,4052],{"class":3293},[56,4080,178],{"class":76},[56,4082,4083],{"class":174},"Yasin",[56,4085,3313],{"class":76},[56,4087,4052],{"class":3293},[56,4089,3297],{"class":76},[56,4091,4092,4094,4097,4099,4102,4104,4106],{"class":58,"line":261},[56,4093,3290],{"class":76},[56,4095,4096],{"class":3293},"soyad",[56,4098,178],{"class":76},[56,4100,4101],{"class":174},"Kenar",[56,4103,3313],{"class":76},[56,4105,4096],{"class":3293},[56,4107,3297],{"class":76},[56,4109,4110,4113,4115],{"class":58,"line":274},[56,4111,4112],{"class":76},"  \u003C\u002F",[56,4114,4070],{"class":3293},[56,4116,3297],{"class":76},[56,4118,4119,4121,4123],{"class":58,"line":279},[56,4120,3313],{"class":76},[56,4122,4025],{"class":3293},[56,4124,3297],{"class":76},[16,4126,4127,4128,4132,4133,4136],{},"But what if there are multiple \"Ders\" objects — how will the output take shape and, before that, how do we generate it 🙂 In the code below I'll create two \"Ogretmen\" objects and use them to create three \"Ders\" objects (between lines 15 and 19). You can check the classes' members on the page I linked above.\nThen I'll add the objects I created to a list (between lines 21 and 24).\nFinally I'll give \"my list\" to the ",[4129,4130,4131],"em",{},"toXML()"," method of my ",[1389,4134,4135],{},"XStream"," object. Yes, in the previous example I passed my \"Ders\" object directly; this time I'm passing the list (between lines 26 and 28).",[47,4138,4141],{"className":4139,"code":4140,"language":1758,"meta":52,"style":52},"language-java shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","package org.sukru.xstream.test;\nimport java.util.ArrayList;\nimport java.util.List;\nimport org.sukru.xstream.entity.Ders;\nimport org.sukru.xstream.entity.Ogretmen;\nimport com.thoughtworks.xstream.XStream;\npublic class XStreamListTest {\n    public static void main(String[] args) {\n        Ogretmen o1 = new Ogretmen(\"Yunus Emre\", \"Aslan\");\n        Ogretmen o2 = new Ogretmen(\"Yasin\", \"Kenar\");\n        Ders d1 = new Ders(1L, \"Türkçe\", o1);\n        Ders d2 = new Ders(2L, \"Arapça\", o2);\n        Ders d3 = new Ders(3L, \"Farsça\", o2);\n        List\u003CDers> dersList = new ArrayList\u003CDers>();\n        dersList.add(d1);\n        dersList.add(d2);\n        dersList.add(d3);\n        XStream xstream = new XStream();\n        xstream.alias(\"Ders\", Ders.class);\n        String xml = xstream.toXML(dersList);\n        System.out.println(xml);\n    }\n}\n",[20,4142,4143,4168,4188,4205,4230,4255,4277,4291,4322,4360,4391,4427,4461,4494,4522,4538,4553,4568,4586,4615,4640,4661,4667],{"__ignoreMap":52},[56,4144,4145,4148,4151,4153,4156,4158,4161,4163,4166],{"class":58,"line":59},[56,4146,4147],{"class":999},"package",[56,4149,4150],{"class":3436}," org",[56,4152,1157],{"class":76},[56,4154,4155],{"class":3436},"sukru",[56,4157,1157],{"class":76},[56,4159,4160],{"class":3436},"xstream",[56,4162,1157],{"class":76},[56,4164,4165],{"class":3436},"test",[56,4167,2606],{"class":76},[56,4169,4170,4173,4176,4178,4181,4183,4186],{"class":58,"line":86},[56,4171,4172],{"class":999},"import",[56,4174,4175],{"class":3436}," java",[56,4177,1157],{"class":76},[56,4179,4180],{"class":3436},"util",[56,4182,1157],{"class":76},[56,4184,4185],{"class":3436},"ArrayList",[56,4187,2606],{"class":76},[56,4189,4190,4192,4194,4196,4198,4200,4203],{"class":58,"line":105},[56,4191,4172],{"class":999},[56,4193,4175],{"class":3436},[56,4195,1157],{"class":76},[56,4197,4180],{"class":3436},[56,4199,1157],{"class":76},[56,4201,4202],{"class":3436},"List",[56,4204,2606],{"class":76},[56,4206,4207,4209,4211,4213,4215,4217,4219,4221,4224,4226,4228],{"class":58,"line":120},[56,4208,4172],{"class":999},[56,4210,4150],{"class":3436},[56,4212,1157],{"class":76},[56,4214,4155],{"class":3436},[56,4216,1157],{"class":76},[56,4218,4160],{"class":3436},[56,4220,1157],{"class":76},[56,4222,4223],{"class":3436},"entity",[56,4225,1157],{"class":76},[56,4227,4025],{"class":3436},[56,4229,2606],{"class":76},[56,4231,4232,4234,4236,4238,4240,4242,4244,4246,4248,4250,4253],{"class":58,"line":248},[56,4233,4172],{"class":999},[56,4235,4150],{"class":3436},[56,4237,1157],{"class":76},[56,4239,4155],{"class":3436},[56,4241,1157],{"class":76},[56,4243,4160],{"class":3436},[56,4245,1157],{"class":76},[56,4247,4223],{"class":3436},[56,4249,1157],{"class":76},[56,4251,4252],{"class":3436},"Ogretmen",[56,4254,2606],{"class":76},[56,4256,4257,4259,4262,4264,4267,4269,4271,4273,4275],{"class":58,"line":261},[56,4258,4172],{"class":999},[56,4260,4261],{"class":3436}," com",[56,4263,1157],{"class":76},[56,4265,4266],{"class":3436},"thoughtworks",[56,4268,1157],{"class":76},[56,4270,4160],{"class":3436},[56,4272,1157],{"class":76},[56,4274,4135],{"class":3436},[56,4276,2606],{"class":76},[56,4278,4279,4282,4285,4288],{"class":58,"line":274},[56,4280,4281],{"class":3436},"public",[56,4283,4284],{"class":3436}," class",[56,4286,4287],{"class":62}," XStreamListTest",[56,4289,4290],{"class":76}," {\n",[56,4292,4293,4296,4299,4302,4304,4307,4310,4313,4317,4320],{"class":58,"line":279},[56,4294,4295],{"class":3436},"    public",[56,4297,4298],{"class":3436}," static",[56,4300,4301],{"class":3436}," void",[56,4303,492],{"class":2666},[56,4305,4306],{"class":76},"(",[56,4308,4309],{"class":3436},"String",[56,4311,4312],{"class":76},"[]",[56,4314,4316],{"class":4315},"sHdIc"," args",[56,4318,4319],{"class":76},")",[56,4321,4290],{"class":76},[56,4323,4324,4327,4330,4332,4335,4338,4340,4342,4345,4347,4350,4352,4355,4357],{"class":58,"line":297},[56,4325,4326],{"class":3436},"        Ogretmen",[56,4328,4329],{"class":174}," o1 ",[56,4331,3440],{"class":76},[56,4333,4334],{"class":2619}," new",[56,4336,4337],{"class":2666}," Ogretmen",[56,4339,4306],{"class":76},[56,4341,312],{"class":76},[56,4343,4344],{"class":66},"Yunus Emre",[56,4346,312],{"class":76},[56,4348,4349],{"class":76},",",[56,4351,77],{"class":76},[56,4353,4354],{"class":66},"Aslan",[56,4356,312],{"class":76},[56,4358,4359],{"class":76},");\n",[56,4361,4362,4364,4367,4369,4371,4373,4375,4377,4379,4381,4383,4385,4387,4389],{"class":58,"line":318},[56,4363,4326],{"class":3436},[56,4365,4366],{"class":174}," o2 ",[56,4368,3440],{"class":76},[56,4370,4334],{"class":2619},[56,4372,4337],{"class":2666},[56,4374,4306],{"class":76},[56,4376,312],{"class":76},[56,4378,4083],{"class":66},[56,4380,312],{"class":76},[56,4382,4349],{"class":76},[56,4384,77],{"class":76},[56,4386,4101],{"class":66},[56,4388,312],{"class":76},[56,4390,4359],{"class":76},[56,4392,4393,4396,4399,4401,4403,4406,4408,4411,4413,4415,4418,4420,4422,4425],{"class":58,"line":813},[56,4394,4395],{"class":3436},"        Ders",[56,4397,4398],{"class":174}," d1 ",[56,4400,3440],{"class":76},[56,4402,4334],{"class":2619},[56,4404,4405],{"class":2666}," Ders",[56,4407,4306],{"class":76},[56,4409,4410],{"class":999},"1L",[56,4412,4349],{"class":76},[56,4414,77],{"class":76},[56,4416,4417],{"class":66},"Türkçe",[56,4419,312],{"class":76},[56,4421,4349],{"class":76},[56,4423,4424],{"class":174}," o1",[56,4426,4359],{"class":76},[56,4428,4429,4431,4434,4436,4438,4440,4442,4445,4447,4449,4452,4454,4456,4459],{"class":58,"line":1913},[56,4430,4395],{"class":3436},[56,4432,4433],{"class":174}," d2 ",[56,4435,3440],{"class":76},[56,4437,4334],{"class":2619},[56,4439,4405],{"class":2666},[56,4441,4306],{"class":76},[56,4443,4444],{"class":999},"2L",[56,4446,4349],{"class":76},[56,4448,77],{"class":76},[56,4450,4451],{"class":66},"Arapça",[56,4453,312],{"class":76},[56,4455,4349],{"class":76},[56,4457,4458],{"class":174}," o2",[56,4460,4359],{"class":76},[56,4462,4463,4465,4468,4470,4472,4474,4476,4479,4481,4483,4486,4488,4490,4492],{"class":58,"line":3654},[56,4464,4395],{"class":3436},[56,4466,4467],{"class":174}," d3 ",[56,4469,3440],{"class":76},[56,4471,4334],{"class":2619},[56,4473,4405],{"class":2666},[56,4475,4306],{"class":76},[56,4477,4478],{"class":999},"3L",[56,4480,4349],{"class":76},[56,4482,77],{"class":76},[56,4484,4485],{"class":66},"Farsça",[56,4487,312],{"class":76},[56,4489,4349],{"class":76},[56,4491,4458],{"class":174},[56,4493,4359],{"class":76},[56,4495,4496,4499,4501,4503,4505,4508,4510,4512,4515,4517,4519],{"class":58,"line":3659},[56,4497,4498],{"class":3436},"        List",[56,4500,3467],{"class":76},[56,4502,4025],{"class":3436},[56,4504,178],{"class":76},[56,4506,4507],{"class":174}," dersList ",[56,4509,3440],{"class":76},[56,4511,4334],{"class":2619},[56,4513,4514],{"class":3436}," ArrayList",[56,4516,3467],{"class":76},[56,4518,4025],{"class":3436},[56,4520,4521],{"class":76},">();\n",[56,4523,4524,4527,4529,4531,4533,4536],{"class":58,"line":3668},[56,4525,4526],{"class":174},"        dersList",[56,4528,1157],{"class":76},[56,4530,194],{"class":2666},[56,4532,4306],{"class":76},[56,4534,4535],{"class":174},"d1",[56,4537,4359],{"class":76},[56,4539,4540,4542,4544,4546,4548,4551],{"class":58,"line":3685},[56,4541,4526],{"class":174},[56,4543,1157],{"class":76},[56,4545,194],{"class":2666},[56,4547,4306],{"class":76},[56,4549,4550],{"class":174},"d2",[56,4552,4359],{"class":76},[56,4554,4555,4557,4559,4561,4563,4566],{"class":58,"line":3702},[56,4556,4526],{"class":174},[56,4558,1157],{"class":76},[56,4560,194],{"class":2666},[56,4562,4306],{"class":76},[56,4564,4565],{"class":174},"d3",[56,4567,4359],{"class":76},[56,4569,4570,4573,4576,4578,4580,4583],{"class":58,"line":3711},[56,4571,4572],{"class":3436},"        XStream",[56,4574,4575],{"class":174}," xstream ",[56,4577,3440],{"class":76},[56,4579,4334],{"class":2619},[56,4581,4582],{"class":2666}," XStream",[56,4584,4585],{"class":76},"();\n",[56,4587,4588,4591,4593,4596,4598,4600,4602,4604,4606,4608,4610,4613],{"class":58,"line":3721},[56,4589,4590],{"class":174},"        xstream",[56,4592,1157],{"class":76},[56,4594,4595],{"class":2666},"alias",[56,4597,4306],{"class":76},[56,4599,312],{"class":76},[56,4601,4025],{"class":66},[56,4603,312],{"class":76},[56,4605,4349],{"class":76},[56,4607,4405],{"class":174},[56,4609,1157],{"class":76},[56,4611,4612],{"class":174},"class",[56,4614,4359],{"class":76},[56,4616,4617,4620,4623,4625,4628,4630,4633,4635,4638],{"class":58,"line":3740},[56,4618,4619],{"class":3436},"        String",[56,4621,4622],{"class":174}," xml ",[56,4624,3440],{"class":76},[56,4626,4627],{"class":174}," xstream",[56,4629,1157],{"class":76},[56,4631,4632],{"class":2666},"toXML",[56,4634,4306],{"class":76},[56,4636,4637],{"class":174},"dersList",[56,4639,4359],{"class":76},[56,4641,4642,4645,4647,4650,4652,4655,4657,4659],{"class":58,"line":3749},[56,4643,4644],{"class":174},"        System",[56,4646,1157],{"class":76},[56,4648,4649],{"class":174},"out",[56,4651,1157],{"class":76},[56,4653,4654],{"class":2666},"println",[56,4656,4306],{"class":76},[56,4658,2995],{"class":174},[56,4660,4359],{"class":76},[56,4662,4664],{"class":58,"line":4663},22,[56,4665,4666],{"class":76},"    }\n",[56,4668,4670],{"class":58,"line":4669},23,[56,4671,4672],{"class":76},"}\n",[16,4674,4675],{},"And finally, when we get the output, the XML looks like this.",[47,4677,4679],{"className":2994,"code":4678,"language":2995,"meta":52,"style":52},"\u003Clist>\n  \u003CDers>\n    \u003Cid>1\u003C\u002Fid>\n    \u003Cad>Türkçe\u003C\u002Fad>\n    \u003Cogretmen>\n      \u003Cad>Yunus Emre\u003C\u002Fad>\n      \u003Csoyad>Aslan\u003C\u002Fsoyad>\n    \u003C\u002Fogretmen>\n  \u003C\u002FDers>\n  \u003CDers>\n    \u003Cid>2\u003C\u002Fid>\n    \u003Cad>Arapça\u003C\u002Fad>\n    \u003Cogretmen>\n      \u003Cad>Yasin\u003C\u002Fad>\n      \u003Csoyad>Kenar\u003C\u002Fsoyad>\n    \u003C\u002Fogretmen>\n  \u003C\u002FDers>\n  \u003CDers>\n    \u003Cid>3\u003C\u002Fid>\n    \u003Cad>Farsça\u003C\u002Fad>\n    \u003Cogretmen reference=\"..\u002F..\u002FDers[2]\u002Fogretmen\"\u002F>\n  \u003C\u002FDers>\n\u003C\u002Flist>\n",[20,4680,4681,4690,4698,4714,4730,4738,4755,4771,4779,4787,4795,4811,4827,4835,4851,4867,4875,4883,4891,4908,4924,4945,4953],{"__ignoreMap":52},[56,4682,4683,4685,4688],{"class":58,"line":59},[56,4684,3467],{"class":76},[56,4686,4687],{"class":3293},"list",[56,4689,3297],{"class":76},[56,4691,4692,4694,4696],{"class":58,"line":86},[56,4693,4032],{"class":76},[56,4695,4025],{"class":3293},[56,4697,3297],{"class":76},[56,4699,4700,4702,4704,4706,4708,4710,4712],{"class":58,"line":105},[56,4701,3290],{"class":76},[56,4703,4035],{"class":3293},[56,4705,178],{"class":76},[56,4707,1000],{"class":174},[56,4709,3313],{"class":76},[56,4711,4035],{"class":3293},[56,4713,3297],{"class":76},[56,4715,4716,4718,4720,4722,4724,4726,4728],{"class":58,"line":120},[56,4717,3290],{"class":76},[56,4719,4052],{"class":3293},[56,4721,178],{"class":76},[56,4723,4417],{"class":174},[56,4725,3313],{"class":76},[56,4727,4052],{"class":3293},[56,4729,3297],{"class":76},[56,4731,4732,4734,4736],{"class":58,"line":248},[56,4733,3290],{"class":76},[56,4735,4070],{"class":3293},[56,4737,3297],{"class":76},[56,4739,4740,4743,4745,4747,4749,4751,4753],{"class":58,"line":261},[56,4741,4742],{"class":76},"      \u003C",[56,4744,4052],{"class":3293},[56,4746,178],{"class":76},[56,4748,4344],{"class":174},[56,4750,3313],{"class":76},[56,4752,4052],{"class":3293},[56,4754,3297],{"class":76},[56,4756,4757,4759,4761,4763,4765,4767,4769],{"class":58,"line":274},[56,4758,4742],{"class":76},[56,4760,4096],{"class":3293},[56,4762,178],{"class":76},[56,4764,4354],{"class":174},[56,4766,3313],{"class":76},[56,4768,4096],{"class":3293},[56,4770,3297],{"class":76},[56,4772,4773,4775,4777],{"class":58,"line":279},[56,4774,3358],{"class":76},[56,4776,4070],{"class":3293},[56,4778,3297],{"class":76},[56,4780,4781,4783,4785],{"class":58,"line":297},[56,4782,4112],{"class":76},[56,4784,4025],{"class":3293},[56,4786,3297],{"class":76},[56,4788,4789,4791,4793],{"class":58,"line":318},[56,4790,4032],{"class":76},[56,4792,4025],{"class":3293},[56,4794,3297],{"class":76},[56,4796,4797,4799,4801,4803,4805,4807,4809],{"class":58,"line":813},[56,4798,3290],{"class":76},[56,4800,4035],{"class":3293},[56,4802,178],{"class":76},[56,4804,1048],{"class":174},[56,4806,3313],{"class":76},[56,4808,4035],{"class":3293},[56,4810,3297],{"class":76},[56,4812,4813,4815,4817,4819,4821,4823,4825],{"class":58,"line":1913},[56,4814,3290],{"class":76},[56,4816,4052],{"class":3293},[56,4818,178],{"class":76},[56,4820,4451],{"class":174},[56,4822,3313],{"class":76},[56,4824,4052],{"class":3293},[56,4826,3297],{"class":76},[56,4828,4829,4831,4833],{"class":58,"line":3654},[56,4830,3290],{"class":76},[56,4832,4070],{"class":3293},[56,4834,3297],{"class":76},[56,4836,4837,4839,4841,4843,4845,4847,4849],{"class":58,"line":3659},[56,4838,4742],{"class":76},[56,4840,4052],{"class":3293},[56,4842,178],{"class":76},[56,4844,4083],{"class":174},[56,4846,3313],{"class":76},[56,4848,4052],{"class":3293},[56,4850,3297],{"class":76},[56,4852,4853,4855,4857,4859,4861,4863,4865],{"class":58,"line":3668},[56,4854,4742],{"class":76},[56,4856,4096],{"class":3293},[56,4858,178],{"class":76},[56,4860,4101],{"class":174},[56,4862,3313],{"class":76},[56,4864,4096],{"class":3293},[56,4866,3297],{"class":76},[56,4868,4869,4871,4873],{"class":58,"line":3685},[56,4870,3358],{"class":76},[56,4872,4070],{"class":3293},[56,4874,3297],{"class":76},[56,4876,4877,4879,4881],{"class":58,"line":3702},[56,4878,4112],{"class":76},[56,4880,4025],{"class":3293},[56,4882,3297],{"class":76},[56,4884,4885,4887,4889],{"class":58,"line":3711},[56,4886,4032],{"class":76},[56,4888,4025],{"class":3293},[56,4890,3297],{"class":76},[56,4892,4893,4895,4897,4899,4902,4904,4906],{"class":58,"line":3721},[56,4894,3290],{"class":76},[56,4896,4035],{"class":3293},[56,4898,178],{"class":76},[56,4900,4901],{"class":174},"3",[56,4903,3313],{"class":76},[56,4905,4035],{"class":3293},[56,4907,3297],{"class":76},[56,4909,4910,4912,4914,4916,4918,4920,4922],{"class":58,"line":3740},[56,4911,3290],{"class":76},[56,4913,4052],{"class":3293},[56,4915,178],{"class":76},[56,4917,4485],{"class":174},[56,4919,3313],{"class":76},[56,4921,4052],{"class":3293},[56,4923,3297],{"class":76},[56,4925,4926,4928,4930,4933,4935,4937,4940,4942],{"class":58,"line":3749},[56,4927,3290],{"class":76},[56,4929,4070],{"class":3293},[56,4931,4932],{"class":3436}," reference",[56,4934,3440],{"class":76},[56,4936,312],{"class":76},[56,4938,4939],{"class":66},"..\u002F..\u002FDers[2]\u002Fogretmen",[56,4941,312],{"class":76},[56,4943,4944],{"class":76},"\u002F>\n",[56,4946,4947,4949,4951],{"class":58,"line":4663},[56,4948,4112],{"class":76},[56,4950,4025],{"class":3293},[56,4952,3297],{"class":76},[56,4954,4955,4957,4959],{"class":58,"line":4669},[56,4956,3313],{"class":76},[56,4958,4687],{"class":3293},[56,4960,3297],{"class":76},[16,4962,4963],{},"What are the differences? Since there are multiple ders objects,",[16,4965,4966],{},"they sit between",[47,4968,4970],{"className":2994,"code":4969,"language":2995,"meta":52,"style":52},"\u003Clist>\n\n\u003C\u002Flist>\n",[20,4971,4972,4980,4984],{"__ignoreMap":52},[56,4973,4974,4976,4978],{"class":58,"line":59},[56,4975,3467],{"class":76},[56,4977,4687],{"class":3293},[56,4979,3297],{"class":76},[56,4981,4982],{"class":58,"line":86},[56,4983,232],{"emptyLinePlaceholder":231},[56,4985,4986,4988,4990],{"class":58,"line":105},[56,4987,3313],{"class":76},[56,4989,4687],{"class":3293},[56,4991,3297],{"class":76},[16,4993,4994],{},"and the \"ogretmen\" info of the \"Ders\" object whose id is 3",[47,4996,4998],{"className":2994,"code":4997,"language":2995,"meta":52,"style":52},"\u003Cogretmen reference=\"..\u002F..\u002FDers[2]\u002Fogretmen\"\u002F>\n",[20,4999,5000],{"__ignoreMap":52},[56,5001,5002,5004,5006,5008,5010,5012,5014,5016],{"class":58,"line":59},[56,5003,3467],{"class":76},[56,5005,4070],{"class":3293},[56,5007,4932],{"class":3436},[56,5009,3440],{"class":76},[56,5011,312],{"class":76},[56,5013,4939],{"class":66},[56,5015,312],{"class":76},[56,5017,4944],{"class":76},[16,5019,5020,5021,5026,5027,5029,5030,5033],{},"is shown as being the same as the \"ogretmen\" info of the \"Ders\" at position 2.\nNow let's get to our main topic: take this XML output, create a new xml file named \"dersler.xml\", and place it under a \"files\" directory we'll create in our project. You can see the project's new structure below.\n",[1646,5022,5024],{"href":5023},"\u002Fimages\u002Fparse-xml-list-into-objects-xstream-xml-reading.png",[2168,5025],{"alt":52,"src":5023},"\nBy reading this xml file we'll assign it to our object via ",[1389,5028,4135],{},"'s ",[4129,5031,5032],{},"fromXML()"," method. Let's write out our steps one by one and implement them.",[1729,5035,5036,5039,5042,5045,5048],{},[1124,5037,5038],{},"Get the file name. (\"files\u002Fdersler.xml\")",[1124,5040,5041],{},"Create an XStream object and define an alias. (Since the object is stored as \"Ders\" in the XML, we must define the alias. If it were stored with its package name it wouldn't be needed.)",[1124,5043,5044],{},"Read this file into a BufferedReader object.",[1124,5046,5047],{},"Pass the BufferedReader object to the fromXML method on the XStream object so it gets the list.",[1124,5049,5050],{},"Iterate the list to show we got the objects back.",[16,5052,5053],{},"If we write the code;",[47,5055,5057],{"className":4139,"code":5056,"language":1758,"meta":52,"style":52},"package org.sukru.xstream.test;\nimport java.io.BufferedReader;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.util.List;\nimport org.sukru.xstream.entity.Ders;\nimport com.thoughtworks.xstream.XStream;\npublic class XStreamReadingListTest {\n    @SuppressWarnings(\"unchecked\")\n    public static void main(String[] args) {\n        String file = \"files\u002Fdersler.xml\";\n        BufferedReader reader = null;\n        XStream xstream = new XStream();\n        xstream.alias(\"Ders\", Ders.class);\n        try {\n            reader = new BufferedReader(new FileReader(file));\n        } catch (FileNotFoundException e) {\n            System.out.println(\"[\" + file + \"] adresinde belirtilen dosya bulunamadı!\");\n            e.printStackTrace();\n        }\n        StringBuffer sb = new StringBuffer();\n        List\u003CDers> dersList = (List\u003CDers>) xstream.fromXML(reader);\n        for (Ders ders : dersList) {\n            sb.append(ders.getId()).append(\" – \").append(ders.getAd()).append(\"\\t\").append(ders.getOgretmen().getAd()).append(\"\\n\");\n        }\n        System.out.println(sb);\n    }\n}\n",[20,5058,5059,5079,5097,5114,5131,5147,5171,5191,5202,5222,5244,5262,5275,5289,5315,5322,5350,5370,5408,5420,5425,5442,5481,5502,5596,5601,5621,5626],{"__ignoreMap":52},[56,5060,5061,5063,5065,5067,5069,5071,5073,5075,5077],{"class":58,"line":59},[56,5062,4147],{"class":999},[56,5064,4150],{"class":3436},[56,5066,1157],{"class":76},[56,5068,4155],{"class":3436},[56,5070,1157],{"class":76},[56,5072,4160],{"class":3436},[56,5074,1157],{"class":76},[56,5076,4165],{"class":3436},[56,5078,2606],{"class":76},[56,5080,5081,5083,5085,5087,5090,5092,5095],{"class":58,"line":86},[56,5082,4172],{"class":999},[56,5084,4175],{"class":3436},[56,5086,1157],{"class":76},[56,5088,5089],{"class":3436},"io",[56,5091,1157],{"class":76},[56,5093,5094],{"class":3436},"BufferedReader",[56,5096,2606],{"class":76},[56,5098,5099,5101,5103,5105,5107,5109,5112],{"class":58,"line":105},[56,5100,4172],{"class":999},[56,5102,4175],{"class":3436},[56,5104,1157],{"class":76},[56,5106,5089],{"class":3436},[56,5108,1157],{"class":76},[56,5110,5111],{"class":3436},"FileNotFoundException",[56,5113,2606],{"class":76},[56,5115,5116,5118,5120,5122,5124,5126,5129],{"class":58,"line":120},[56,5117,4172],{"class":999},[56,5119,4175],{"class":3436},[56,5121,1157],{"class":76},[56,5123,5089],{"class":3436},[56,5125,1157],{"class":76},[56,5127,5128],{"class":3436},"FileReader",[56,5130,2606],{"class":76},[56,5132,5133,5135,5137,5139,5141,5143,5145],{"class":58,"line":248},[56,5134,4172],{"class":999},[56,5136,4175],{"class":3436},[56,5138,1157],{"class":76},[56,5140,4180],{"class":3436},[56,5142,1157],{"class":76},[56,5144,4202],{"class":3436},[56,5146,2606],{"class":76},[56,5148,5149,5151,5153,5155,5157,5159,5161,5163,5165,5167,5169],{"class":58,"line":261},[56,5150,4172],{"class":999},[56,5152,4150],{"class":3436},[56,5154,1157],{"class":76},[56,5156,4155],{"class":3436},[56,5158,1157],{"class":76},[56,5160,4160],{"class":3436},[56,5162,1157],{"class":76},[56,5164,4223],{"class":3436},[56,5166,1157],{"class":76},[56,5168,4025],{"class":3436},[56,5170,2606],{"class":76},[56,5172,5173,5175,5177,5179,5181,5183,5185,5187,5189],{"class":58,"line":274},[56,5174,4172],{"class":999},[56,5176,4261],{"class":3436},[56,5178,1157],{"class":76},[56,5180,4266],{"class":3436},[56,5182,1157],{"class":76},[56,5184,4160],{"class":3436},[56,5186,1157],{"class":76},[56,5188,4135],{"class":3436},[56,5190,2606],{"class":76},[56,5192,5193,5195,5197,5200],{"class":58,"line":279},[56,5194,4281],{"class":3436},[56,5196,4284],{"class":3436},[56,5198,5199],{"class":62}," XStreamReadingListTest",[56,5201,4290],{"class":76},[56,5203,5204,5207,5210,5212,5214,5217,5219],{"class":58,"line":297},[56,5205,5206],{"class":76},"    @",[56,5208,5209],{"class":3436},"SuppressWarnings",[56,5211,4306],{"class":76},[56,5213,312],{"class":76},[56,5215,5216],{"class":66},"unchecked",[56,5218,312],{"class":76},[56,5220,5221],{"class":76},")\n",[56,5223,5224,5226,5228,5230,5232,5234,5236,5238,5240,5242],{"class":58,"line":318},[56,5225,4295],{"class":3436},[56,5227,4298],{"class":3436},[56,5229,4301],{"class":3436},[56,5231,492],{"class":2666},[56,5233,4306],{"class":76},[56,5235,4309],{"class":3436},[56,5237,4312],{"class":76},[56,5239,4316],{"class":4315},[56,5241,4319],{"class":76},[56,5243,4290],{"class":76},[56,5245,5246,5248,5251,5253,5255,5258,5260],{"class":58,"line":813},[56,5247,4619],{"class":3436},[56,5249,5250],{"class":174}," file ",[56,5252,3440],{"class":76},[56,5254,77],{"class":76},[56,5256,5257],{"class":66},"files\u002Fdersler.xml",[56,5259,312],{"class":76},[56,5261,2606],{"class":76},[56,5263,5264,5267,5270,5272],{"class":58,"line":1913},[56,5265,5266],{"class":3436},"        BufferedReader",[56,5268,5269],{"class":174}," reader ",[56,5271,3440],{"class":76},[56,5273,5274],{"class":76}," null;\n",[56,5276,5277,5279,5281,5283,5285,5287],{"class":58,"line":3654},[56,5278,4572],{"class":3436},[56,5280,4575],{"class":174},[56,5282,3440],{"class":76},[56,5284,4334],{"class":2619},[56,5286,4582],{"class":2666},[56,5288,4585],{"class":76},[56,5290,5291,5293,5295,5297,5299,5301,5303,5305,5307,5309,5311,5313],{"class":58,"line":3659},[56,5292,4590],{"class":174},[56,5294,1157],{"class":76},[56,5296,4595],{"class":2666},[56,5298,4306],{"class":76},[56,5300,312],{"class":76},[56,5302,4025],{"class":66},[56,5304,312],{"class":76},[56,5306,4349],{"class":76},[56,5308,4405],{"class":174},[56,5310,1157],{"class":76},[56,5312,4612],{"class":174},[56,5314,4359],{"class":76},[56,5316,5317,5320],{"class":58,"line":3668},[56,5318,5319],{"class":2619},"        try",[56,5321,4290],{"class":76},[56,5323,5324,5327,5329,5331,5334,5336,5339,5342,5344,5347],{"class":58,"line":3685},[56,5325,5326],{"class":174},"            reader ",[56,5328,3440],{"class":76},[56,5330,4334],{"class":2619},[56,5332,5333],{"class":2666}," BufferedReader",[56,5335,4306],{"class":76},[56,5337,5338],{"class":2619},"new",[56,5340,5341],{"class":2666}," FileReader",[56,5343,4306],{"class":76},[56,5345,5346],{"class":174},"file",[56,5348,5349],{"class":76},"));\n",[56,5351,5352,5355,5358,5361,5363,5366,5368],{"class":58,"line":3702},[56,5353,5354],{"class":76},"        }",[56,5356,5357],{"class":2619}," catch",[56,5359,5360],{"class":76}," (",[56,5362,5111],{"class":3436},[56,5364,5365],{"class":4315}," e",[56,5367,4319],{"class":76},[56,5369,4290],{"class":76},[56,5371,5372,5375,5377,5379,5381,5383,5385,5387,5389,5391,5394,5396,5399,5401,5404,5406],{"class":58,"line":3711},[56,5373,5374],{"class":174},"            System",[56,5376,1157],{"class":76},[56,5378,4649],{"class":174},[56,5380,1157],{"class":76},[56,5382,4654],{"class":2666},[56,5384,4306],{"class":76},[56,5386,312],{"class":76},[56,5388,2880],{"class":66},[56,5390,312],{"class":76},[56,5392,5393],{"class":76}," +",[56,5395,5250],{"class":174},[56,5397,5398],{"class":76},"+",[56,5400,77],{"class":76},[56,5402,5403],{"class":66},"] adresinde belirtilen dosya bulunamadı!",[56,5405,312],{"class":76},[56,5407,4359],{"class":76},[56,5409,5410,5413,5415,5418],{"class":58,"line":3721},[56,5411,5412],{"class":174},"            e",[56,5414,1157],{"class":76},[56,5416,5417],{"class":2666},"printStackTrace",[56,5419,4585],{"class":76},[56,5421,5422],{"class":58,"line":3740},[56,5423,5424],{"class":76},"        }\n",[56,5426,5427,5430,5433,5435,5437,5440],{"class":58,"line":3749},[56,5428,5429],{"class":3436},"        StringBuffer",[56,5431,5432],{"class":174}," sb ",[56,5434,3440],{"class":76},[56,5436,4334],{"class":2619},[56,5438,5439],{"class":2666}," StringBuffer",[56,5441,4585],{"class":76},[56,5443,5444,5446,5448,5450,5452,5454,5456,5458,5460,5462,5464,5467,5469,5471,5474,5476,5479],{"class":58,"line":4663},[56,5445,4498],{"class":3436},[56,5447,3467],{"class":76},[56,5449,4025],{"class":3436},[56,5451,178],{"class":76},[56,5453,4507],{"class":174},[56,5455,3440],{"class":76},[56,5457,5360],{"class":76},[56,5459,4202],{"class":3436},[56,5461,3467],{"class":76},[56,5463,4025],{"class":174},[56,5465,5466],{"class":76},">)",[56,5468,4627],{"class":174},[56,5470,1157],{"class":76},[56,5472,5473],{"class":2666},"fromXML",[56,5475,4306],{"class":76},[56,5477,5478],{"class":174},"reader",[56,5480,4359],{"class":76},[56,5482,5483,5486,5488,5490,5493,5495,5498,5500],{"class":58,"line":4669},[56,5484,5485],{"class":2619},"        for",[56,5487,5360],{"class":76},[56,5489,4025],{"class":3436},[56,5491,5492],{"class":174}," ders ",[56,5494,3476],{"class":2619},[56,5496,5497],{"class":174}," dersList",[56,5499,4319],{"class":76},[56,5501,4290],{"class":76},[56,5503,5505,5508,5510,5513,5515,5518,5520,5523,5526,5528,5530,5532,5535,5537,5539,5541,5543,5545,5547,5550,5552,5554,5556,5558,5561,5563,5565,5567,5569,5571,5573,5576,5579,5581,5583,5585,5587,5589,5592,5594],{"class":58,"line":5504},24,[56,5506,5507],{"class":174},"            sb",[56,5509,1157],{"class":76},[56,5511,5512],{"class":2666},"append",[56,5514,4306],{"class":76},[56,5516,5517],{"class":174},"ders",[56,5519,1157],{"class":76},[56,5521,5522],{"class":2666},"getId",[56,5524,5525],{"class":76},"()).",[56,5527,5512],{"class":2666},[56,5529,4306],{"class":76},[56,5531,312],{"class":76},[56,5533,5534],{"class":66}," – ",[56,5536,312],{"class":76},[56,5538,199],{"class":76},[56,5540,5512],{"class":2666},[56,5542,4306],{"class":76},[56,5544,5517],{"class":174},[56,5546,1157],{"class":76},[56,5548,5549],{"class":2666},"getAd",[56,5551,5525],{"class":76},[56,5553,5512],{"class":2666},[56,5555,4306],{"class":76},[56,5557,312],{"class":76},[56,5559,5560],{"class":174},"\\t",[56,5562,312],{"class":76},[56,5564,199],{"class":76},[56,5566,5512],{"class":2666},[56,5568,4306],{"class":76},[56,5570,5517],{"class":174},[56,5572,1157],{"class":76},[56,5574,5575],{"class":2666},"getOgretmen",[56,5577,5578],{"class":76},"().",[56,5580,5549],{"class":2666},[56,5582,5525],{"class":76},[56,5584,5512],{"class":2666},[56,5586,4306],{"class":76},[56,5588,312],{"class":76},[56,5590,5591],{"class":174},"\\n",[56,5593,312],{"class":76},[56,5595,4359],{"class":76},[56,5597,5599],{"class":58,"line":5598},25,[56,5600,5424],{"class":76},[56,5602,5604,5606,5608,5610,5612,5614,5616,5619],{"class":58,"line":5603},26,[56,5605,4644],{"class":174},[56,5607,1157],{"class":76},[56,5609,4649],{"class":174},[56,5611,1157],{"class":76},[56,5613,4654],{"class":2666},[56,5615,4306],{"class":76},[56,5617,5618],{"class":174},"sb",[56,5620,4359],{"class":76},[56,5622,5624],{"class":58,"line":5623},27,[56,5625,4666],{"class":76},[56,5627,5629],{"class":58,"line":5628},28,[56,5630,4672],{"class":76},[16,5632,5633],{},"We printed to the screen at the end — let's give the output too 🙂",[47,5635,5638],{"className":5636,"code":5637,"language":1226},[1224],"1 - Türkçe  Yunus Emre\n\n2 - Arapça  Yasin\n\n3 - Farsça  Yasin\n",[20,5639,5637],{"__ignoreMap":52},[16,5641,5642],{},"If you compile this code in your own environment and debug it step by step, you'll understand it much better.\nTake it easy.",[1188,5644,5645],{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":52,"searchDepth":86,"depth":86,"links":5647},[],"2011-08-11","Converting list elements in an XML file into Java objects.",{},"\u002Fen\u002Fblog\u002Fparse-xml-list-into-objects",{"title":4002,"description":5649},"en\u002Fblog\u002Fparse-xml-list-into-objects",[1758,2995],"\u002Fblog\u002Fparse-xml-list-into-objects","0sdkPsEpI2SzynSmtLlPK7cLkfqZBx2fgqD-z8Cn774",{"id":5658,"title":5659,"body":5660,"date":5867,"description":5868,"extension":1203,"meta":5869,"navigation":231,"path":5870,"seo":5871,"stem":5872,"tags":5873,"translation":5874,"__hash__":5875},"pages_en\u002Fen\u002Fblog\u002Fjava-package.md","Java Package",{"type":8,"value":5661,"toc":5865},[5662,5665,5680,5685,5696,5723,5726,5749,5752,5757,5838,5841,5843,5848,5862],[16,5663,5664],{},"The Java Package concept is used to organize Java classes in a tidy way. Classes in the same category or with similar responsibilities are grouped together to provide logical integrity. You can think of it like folders on your computer; keep my music here, put my pictures there…",[1121,5666,5667,5677],{},[1124,5668,5669,5670,5672,5673,5676],{},"A \"package\" creates a unique namespace for a Java class. For example, the ",[1389,5671,4309],{}," class is unique under the ",[1389,5674,5675],{},"java.lang"," package, and the package it lives in is unique too.",[1124,5678,5679],{},"Classes in the same package become each other's \"package-access members\" — members accessible at package level. This concept may feel abstract right now; we'll dig into \"access\" in detail in another post where it will make more sense.",[16,5681,5682],{},[1389,5683,5684],{},"Naming Convention",[16,5686,5687,5688,5695],{},"Like most software conventions, this isn't mandatory but it's a structure people can understand and agree on more easily when followed. For example, I currently work at a company called ",[1389,5689,5690],{},[1646,5691,5694],{"href":5692,"rel":5693},"http:\u002F\u002Fwww.i2i-systems.com",[1650],"i2i systems"," and I'm writing a commercial application called \"EasyProv\"; I want to group the utilities I frequently use in the application under a package;",[47,5697,5699],{"className":4139,"code":5698,"language":1758,"meta":52,"style":52},"package com.i2i.easyprov.util;\n",[20,5700,5701],{"__ignoreMap":52},[56,5702,5703,5705,5707,5709,5712,5714,5717,5719,5721],{"class":58,"line":59},[56,5704,4147],{"class":999},[56,5706,4261],{"class":3436},[56,5708,1157],{"class":76},[56,5710,5711],{"class":3436},"i2i",[56,5713,1157],{"class":76},[56,5715,5716],{"class":3436},"easyprov",[56,5718,1157],{"class":76},[56,5720,4180],{"class":3436},[56,5722,2606],{"class":76},[16,5724,5725],{},"Reading it again we get the following information;",[1729,5727,5728,5734,5739,5744],{},[1124,5729,5730,5733],{},[1389,5731,5732],{},"com"," – a commercial package",[1124,5735,5736,5738],{},[1389,5737,5711],{}," – written by the i2i company",[1124,5740,5741,5743],{},[1389,5742,5716],{}," – belongs to the easyprov project",[1124,5745,5746,5748],{},[1389,5747,4180],{}," – utilities live here",[16,5750,5751],{},"In short, what I can find under this package is visible upfront 🙂",[16,5753,5754],{},[1389,5755,5756],{},"Some of Java's core packages…",[1121,5758,5759,5766,5774,5782,5790,5798,5806,5814,5822,5830],{},[1124,5760,5761,5765],{},[1646,5762,5675],{"href":5763,"rel":5764},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002Fjava\u002Flang\u002Fpackage-summary.html",[1650]," \t— the package with the language's functionality and basic types, like String, Integer…",[1124,5767,5768,5773],{},[1646,5769,5772],{"href":5770,"rel":5771},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002Fjava\u002Futil\u002Fpackage-summary.html",[1650],"java.util","\t— classes for collection data structures",[1124,5775,5776,5781],{},[1646,5777,5780],{"href":5778,"rel":5779},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002Fjava\u002Fio\u002Fpackage-summary.html",[1650],"java.io"," \t— file operations",[1124,5783,5784,5789],{},[1646,5785,5788],{"href":5786,"rel":5787},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002F\u002Fjava\u002Fmath\u002Fpackage-summary.html",[1650],"java.math"," \t— mathematical operations",[1124,5791,5792,5797],{},[1646,5793,5796],{"href":5794,"rel":5795},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002Fjava\u002Fnet\u002Fpackage-summary.html",[1650],"java.net"," \t— network operations, socket programming, etc…",[1124,5799,5800,5805],{},[1646,5801,5804],{"href":5802,"rel":5803},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002Fjava\u002Fsecurity\u002Fpackage-summary.html",[1650],"java.security"," \t— key generation, encryption, decryption…",[1124,5807,5808,5813],{},[1646,5809,5812],{"href":5810,"rel":5811},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002Fjava\u002Fsql\u002Fpackage-summary.html",[1650],"java.sql"," \t— Java Database Connectivity (JDBC) for accessing databases",[1124,5815,5816,5821],{},[1646,5817,5820],{"href":5818,"rel":5819},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002Fjava\u002Fawt\u002Fpackage-summary.html",[1650],"java.awt"," \t— the visual UI component package for desktop applications",[1124,5823,5824,5829],{},[1646,5825,5828],{"href":5826,"rel":5827},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002Fjavax\u002Fswing\u002Fpackage-summary.html",[1650],"javax.swing"," \t— like awt but a platform-independent UI component package",[1124,5831,5832,5837],{},[1646,5833,5836],{"href":5834,"rel":5835},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002F6\u002Fdocs\u002Fapi\u002Fjava\u002Fapplet\u002Fpackage-summary.html",[1650],"java.applet"," \t— the package containing classes for developing applets",[16,5839,5840],{},"Hope it was useful 🙂 may the \"default package\" be the one you hate most.",[16,5842,2196],{},[16,5844,5845],{},[1389,5846,5847],{},"Resources",[1729,5849,5850,5856],{},[1124,5851,5852],{},[1646,5853,5854],{"href":5854,"rel":5855},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002Ftutorial\u002Fjava\u002Fconcepts\u002Fpackage.html",[1650],[1124,5857,5858],{},[1646,5859,5860],{"href":5860,"rel":5861},"http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FJava_package",[1650],[1188,5863,5864],{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":52,"searchDepth":86,"depth":86,"links":5866},[],"2011-08-01","The package concept in Java: organizing classes, preventing name clashes, and access control.",{},"\u002Fen\u002Fblog\u002Fjava-package",{"title":5659,"description":5868},"en\u002Fblog\u002Fjava-package",[1758],"\u002Fblog\u002Fjava-package","DIIMNXP2oTlIY_z22-adqSKdC5A14nQHk5_Y9H_rbIM",{"id":5877,"title":5878,"body":5879,"date":6000,"description":6001,"extension":1203,"meta":6002,"navigation":231,"path":6003,"seo":6004,"stem":6005,"tags":6006,"translation":6008,"__hash__":6009},"pages_en\u002Fen\u002Fblog\u002Fintroduction-to-exception-handling.md","Introduction to Exception Handling",{"type":8,"value":5880,"toc":5998},[5881,5896,5912,5917,5924,5931,5938,5943,5954,5959,5965,5970,5980,5984],[16,5882,5883,5884,5889,5890,5895],{},"In Java, the concept of \"exceptions\" is used for catching errors and handling exceptional situations. It's essential for robust software, yet it's often neglected. Let's not neglect it.\nAn \"exception\" is an event that interrupts the normal flow of a program's execution. In the picture below we see a flow going up from the \"main\" method, and at the last step an error occurs. From the point where the error happened, the code starts looking for a part that can handle it (exception handler), this time in reverse order. Once it finds the exception handler, it passes the error to the appropriate handler.\n",[1646,5885,5887],{"href":5886},"\u002Fimages\u002Fintroduction-to-exception-handling-exceptions-callstack.gif",[2168,5888],{"alt":52,"src":5886},"\nWe call these operations catching the exception.\n",[1646,5891,5893],{"href":5892},"\u002Fimages\u002Fintroduction-to-exception-handling-exceptions-errorOccurs.gif",[2168,5894],{"alt":52,"src":5892},"\nException handling can be done:",[1121,5897,5898,5905],{},[1124,5899,5900,5901,5904],{},"by catching it inside a ",[20,5902,5903],{},"try"," code block, or",[1124,5906,5907,5908,5911],{},"by declaring it with a ",[20,5909,5910],{},"throws"," clause at the method signature.",[2242,5913,5914],{},[16,5915,5916],{},"There are 3 types of errors;",[2242,5918,5919],{},[1729,5920,5921],{},[1124,5922,5923],{},"Checked Exception",[2242,5925,5926],{},[1729,5927,5928],{"start":86},[1124,5929,5930],{},"Error",[2242,5932,5933],{},[1729,5934,5935],{"start":105},[1124,5936,5937],{},"Runtime Exception",[16,5939,5940],{},[1389,5941,5942],{},"1. Checked Exception",[16,5944,5945,5946,5949,5950,5953],{},"For example, you're reading a file using an object of the ",[20,5947,5948],{},"java.io.FileReader"," class; you give it a filename and it can't find the file, so it throws a ",[20,5951,5952],{},"java.io.FileNotFoundException",". In a well-written program you catch this in a try-catch block, inform the user about the error, and let them fix the filename.\nEvery situation other than \"Error\" or \"Runtime Exception\" is a \"Checked Exception\".",[16,5955,5956],{},[1389,5957,5958],{},"2. Error",[16,5960,5961,5962,1157],{},"These are situations caused by external systems outside your application. For example, you want to read a file but your file system — say the disk — can't be reached; that's where an \"Error\" type situation occurs, and the application throws a ",[20,5963,5964],{},"java.io.IOError",[16,5966,5967],{},[1389,5968,5969],{},"3. Runtime Exception",[16,5971,5972,5973,5976,5977,5979],{},"This is a situation that occurs while your application is running. It stems from the application itself — it's a bug in the program, a logic error, or a result of misusing the API 🙂 And yes, I've done it like everyone else, and I've usually gotten a ",[20,5974,5975],{},"NullPointerException"," — that's why 🙂\nTo make it clearer with an example: you want to read a file but didn't provide a filename — well, what happens? You'll get a ",[20,5978,5975],{},". That is, the application will have \"blown up\" at runtime — as they usually say.\nBy the way, \"Error\" and \"Runtime Exception\" together are also called \"Unchecked Exceptions\".\nI think this much information is enough as an introduction — enough for it to stick in your mind. In my next post on this topic we'll write plenty of code 🙂\nTake it easy.",[16,5981,5982],{},[1389,5983,5847],{},[1729,5985,5986,5992],{},[1124,5987,5988],{},[1646,5989,5990],{"href":5990,"rel":5991},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002Ftutorial\u002Fessential\u002Fexceptions\u002F",[1650],[1124,5993,5994],{},[1646,5995,5996],{"href":5996,"rel":5997},"http:\u002F\u002Ftutorials.jenkov.com\u002Fjava-exception-handling\u002Findex.html",[1650],{"title":52,"searchDepth":86,"depth":86,"links":5999},[],"2011-07-26","An introduction to exception handling in Java: the try-catch mechanism and the checked\u002Funchecked distinction.",{},"\u002Fen\u002Fblog\u002Fintroduction-to-exception-handling",{"title":5878,"description":6001},"en\u002Fblog\u002Fintroduction-to-exception-handling",[6007,1758],"exceptions","\u002Fblog\u002Fintroduction-to-exception-handling","kvgQKXZLpxhaLjgS9_85_24YGaR-wx3FmV-wqCPw898",{"id":6011,"title":6012,"body":6013,"date":6666,"description":6667,"extension":1203,"meta":6668,"navigation":231,"path":6669,"seo":6670,"stem":6671,"tags":6672,"translation":6673,"__hash__":6674},"pages_en\u002Fen\u002Fblog\u002Fgeneric-types.md","Generic Types",{"type":8,"value":6014,"toc":6664},[6015,6036,6150,6157,6328,6338,6455,6462,6472,6615,6626,6646,6649,6661],[16,6016,6017,6018,6021,6022,6024,6025,6028,6029,6032,6033,6035],{},"In programming, sometimes the types of certain values can't be predicted. While you expect the incoming value to be an ",[20,6019,6020],{},"Integer",", lo and behold a ",[20,6023,4309],{}," arrives; your application gets a ",[20,6026,6027],{},"java.lang.ClassCastException"," saying ",[20,6030,6031],{},"java.lang.String cannot be cast to java.lang.Integer",", meaning the incoming String value couldn't be converted to Integer.\nThat's exactly where the ",[1389,6034,6012],{}," concept comes in.\nNow, to demonstrate what I described above, here's an example where we run into the error. There's a class named Box that has a variable of type Object.",[47,6037,6039],{"className":4139,"code":6038,"language":1758,"meta":52,"style":52},"package org.sukru.classic;\npublic class Box {\n    private Object object;\n    public void add(Object object) {\n        this.object = object;\n    }\n    public Object get() {\n        return object;\n    }\n}\n",[20,6040,6041,6058,6069,6082,6101,6115,6119,6133,6142,6146],{"__ignoreMap":52},[56,6042,6043,6045,6047,6049,6051,6053,6056],{"class":58,"line":59},[56,6044,4147],{"class":999},[56,6046,4150],{"class":3436},[56,6048,1157],{"class":76},[56,6050,4155],{"class":3436},[56,6052,1157],{"class":76},[56,6054,6055],{"class":3436},"classic",[56,6057,2606],{"class":76},[56,6059,6060,6062,6064,6067],{"class":58,"line":86},[56,6061,4281],{"class":3436},[56,6063,4284],{"class":3436},[56,6065,6066],{"class":62}," Box",[56,6068,4290],{"class":76},[56,6070,6071,6074,6077,6080],{"class":58,"line":105},[56,6072,6073],{"class":3436},"    private",[56,6075,6076],{"class":3436}," Object",[56,6078,6079],{"class":174}," object",[56,6081,2606],{"class":76},[56,6083,6084,6086,6088,6090,6092,6095,6097,6099],{"class":58,"line":120},[56,6085,4295],{"class":3436},[56,6087,4301],{"class":3436},[56,6089,239],{"class":2666},[56,6091,4306],{"class":76},[56,6093,6094],{"class":3436},"Object",[56,6096,6079],{"class":4315},[56,6098,4319],{"class":76},[56,6100,4290],{"class":76},[56,6102,6103,6106,6109,6111,6113],{"class":58,"line":248},[56,6104,6105],{"class":76},"        this.",[56,6107,6108],{"class":174},"object ",[56,6110,3440],{"class":76},[56,6112,6079],{"class":174},[56,6114,2606],{"class":76},[56,6116,6117],{"class":58,"line":261},[56,6118,4666],{"class":76},[56,6120,6121,6123,6125,6128,6131],{"class":58,"line":274},[56,6122,4295],{"class":3436},[56,6124,6076],{"class":3436},[56,6126,6127],{"class":2666}," get",[56,6129,6130],{"class":76},"()",[56,6132,4290],{"class":76},[56,6134,6135,6138,6140],{"class":58,"line":279},[56,6136,6137],{"class":2619},"        return",[56,6139,6079],{"class":174},[56,6141,2606],{"class":76},[56,6143,6144],{"class":58,"line":297},[56,6145,4666],{"class":76},[56,6147,6148],{"class":58,"line":318},[56,6149,4672],{"class":76},[16,6151,6152,6153,6156],{},"Whatever type the variable we pass to add() is, it will accept it — but in the get() method we'll inevitably have to \"",[1389,6154,6155],{},"cast","\".",[47,6158,6160],{"className":4139,"code":6159,"language":1758,"meta":52,"style":52},"package org.sukru.classic;\nimport org.sukru.classic.Box;\npublic class BoxTest {\n    public static void main(String[] args) {\n        Box integerBox = new Box();\n        integerBox.add(new Integer(10)); \u002F\u002F What if I added a String here?\n        Integer someInteger = (Integer) integerBox.get();\n        System.out.println(someInteger);\n    }\n}\n",[20,6161,6162,6178,6199,6210,6232,6248,6275,6301,6320,6324],{"__ignoreMap":52},[56,6163,6164,6166,6168,6170,6172,6174,6176],{"class":58,"line":59},[56,6165,4147],{"class":999},[56,6167,4150],{"class":3436},[56,6169,1157],{"class":76},[56,6171,4155],{"class":3436},[56,6173,1157],{"class":76},[56,6175,6055],{"class":3436},[56,6177,2606],{"class":76},[56,6179,6180,6182,6184,6186,6188,6190,6192,6194,6197],{"class":58,"line":86},[56,6181,4172],{"class":999},[56,6183,4150],{"class":3436},[56,6185,1157],{"class":76},[56,6187,4155],{"class":3436},[56,6189,1157],{"class":76},[56,6191,6055],{"class":3436},[56,6193,1157],{"class":76},[56,6195,6196],{"class":3436},"Box",[56,6198,2606],{"class":76},[56,6200,6201,6203,6205,6208],{"class":58,"line":105},[56,6202,4281],{"class":3436},[56,6204,4284],{"class":3436},[56,6206,6207],{"class":62}," BoxTest",[56,6209,4290],{"class":76},[56,6211,6212,6214,6216,6218,6220,6222,6224,6226,6228,6230],{"class":58,"line":120},[56,6213,4295],{"class":3436},[56,6215,4298],{"class":3436},[56,6217,4301],{"class":3436},[56,6219,492],{"class":2666},[56,6221,4306],{"class":76},[56,6223,4309],{"class":3436},[56,6225,4312],{"class":76},[56,6227,4316],{"class":4315},[56,6229,4319],{"class":76},[56,6231,4290],{"class":76},[56,6233,6234,6237,6240,6242,6244,6246],{"class":58,"line":248},[56,6235,6236],{"class":3436},"        Box",[56,6238,6239],{"class":174}," integerBox ",[56,6241,3440],{"class":76},[56,6243,4334],{"class":2619},[56,6245,6066],{"class":2666},[56,6247,4585],{"class":76},[56,6249,6250,6253,6255,6257,6259,6261,6264,6266,6269,6272],{"class":58,"line":261},[56,6251,6252],{"class":174},"        integerBox",[56,6254,1157],{"class":76},[56,6256,194],{"class":2666},[56,6258,4306],{"class":76},[56,6260,5338],{"class":2619},[56,6262,6263],{"class":2666}," Integer",[56,6265,4306],{"class":76},[56,6267,6268],{"class":999},"10",[56,6270,6271],{"class":76},"));",[56,6273,6274],{"class":130}," \u002F\u002F What if I added a String here?\n",[56,6276,6277,6280,6283,6285,6287,6289,6291,6294,6296,6299],{"class":58,"line":274},[56,6278,6279],{"class":3436},"        Integer",[56,6281,6282],{"class":174}," someInteger ",[56,6284,3440],{"class":76},[56,6286,5360],{"class":76},[56,6288,6020],{"class":174},[56,6290,4319],{"class":76},[56,6292,6293],{"class":174}," integerBox",[56,6295,1157],{"class":76},[56,6297,6298],{"class":2666},"get",[56,6300,4585],{"class":76},[56,6302,6303,6305,6307,6309,6311,6313,6315,6318],{"class":58,"line":279},[56,6304,4644],{"class":174},[56,6306,1157],{"class":76},[56,6308,4649],{"class":174},[56,6310,1157],{"class":76},[56,6312,4654],{"class":2666},[56,6314,4306],{"class":76},[56,6316,6317],{"class":174},"someInteger",[56,6319,4359],{"class":76},[56,6321,6322],{"class":58,"line":297},[56,6323,4666],{"class":76},[56,6325,6326],{"class":58,"line":318},[56,6327,4672],{"class":76},[16,6329,6330,6331,6334,6335,6337],{},"Well, when we run this code there's no problem so far — but as I noted inside the code, what if I had passed the parameter as a String like ",[20,6332,6333],{},"integerBox.add(\"10\");","? That's when we'd get the ",[20,6336,6027],{}," I mentioned at the start.\nOn to the solution: if we declare the Box class as a generic type with the expression below, whatever comes in is fine 🙂 By the way, note that although the class names are the same, I'm working under a different package.",[47,6339,6341],{"className":4139,"code":6340,"language":1758,"meta":52,"style":52},"package org.sukru.generics;\npublic class Box\u003CT> {\n    private T t; \u002F\u002F T here means \"Type\".\n    public void add(T t) {\n        this.t = t;\n    }\n    public T get() {\n        return t;\n    }\n}\n",[20,6342,6343,6360,6377,6392,6410,6423,6427,6439,6447,6451],{"__ignoreMap":52},[56,6344,6345,6347,6349,6351,6353,6355,6358],{"class":58,"line":59},[56,6346,4147],{"class":999},[56,6348,4150],{"class":3436},[56,6350,1157],{"class":76},[56,6352,4155],{"class":3436},[56,6354,1157],{"class":76},[56,6356,6357],{"class":3436},"generics",[56,6359,2606],{"class":76},[56,6361,6362,6364,6366,6368,6370,6373,6375],{"class":58,"line":86},[56,6363,4281],{"class":3436},[56,6365,4284],{"class":3436},[56,6367,6066],{"class":62},[56,6369,3467],{"class":76},[56,6371,6372],{"class":3436},"T",[56,6374,178],{"class":76},[56,6376,4290],{"class":76},[56,6378,6379,6381,6384,6387,6389],{"class":58,"line":105},[56,6380,6073],{"class":3436},[56,6382,6383],{"class":3436}," T",[56,6385,6386],{"class":174}," t",[56,6388,2909],{"class":76},[56,6390,6391],{"class":130}," \u002F\u002F T here means \"Type\".\n",[56,6393,6394,6396,6398,6400,6402,6404,6406,6408],{"class":58,"line":120},[56,6395,4295],{"class":3436},[56,6397,4301],{"class":3436},[56,6399,239],{"class":2666},[56,6401,4306],{"class":76},[56,6403,6372],{"class":3436},[56,6405,6386],{"class":4315},[56,6407,4319],{"class":76},[56,6409,4290],{"class":76},[56,6411,6412,6414,6417,6419,6421],{"class":58,"line":248},[56,6413,6105],{"class":76},[56,6415,6416],{"class":174},"t ",[56,6418,3440],{"class":76},[56,6420,6386],{"class":174},[56,6422,2606],{"class":76},[56,6424,6425],{"class":58,"line":261},[56,6426,4666],{"class":76},[56,6428,6429,6431,6433,6435,6437],{"class":58,"line":274},[56,6430,4295],{"class":3436},[56,6432,6383],{"class":3436},[56,6434,6127],{"class":2666},[56,6436,6130],{"class":76},[56,6438,4290],{"class":76},[56,6440,6441,6443,6445],{"class":58,"line":279},[56,6442,6137],{"class":2619},[56,6444,6386],{"class":174},[56,6446,2606],{"class":76},[56,6448,6449],{"class":58,"line":297},[56,6450,4666],{"class":76},[56,6452,6453],{"class":58,"line":318},[56,6454,4672],{"class":76},[16,6456,6457,6458,6461],{},"If we unpack the meaning of the T in the ",[20,6459,6460],{},"Box\u003CT>"," expression above, we can say it stands for \"Type\" — meaning an object of any type can be defined from this class.",[16,6463,6464,6465,665,6468,6471],{},"It could be ",[20,6466,6467],{},"Box\u003CInteger> integerBox = new Box\u003CInteger>();",[20,6469,6470],{},"Box\u003CString> integerBox = new Box\u003CString>(); "," or any other type — except primitive types!\nNow, building on this, we'll produce a Box object of type Integer and continue from there.",[47,6473,6475],{"className":4139,"code":6474,"language":1758,"meta":52,"style":52},"package org.sukru.generics;\npublic class BoxTest {\n    public static void main(String[] args) {\n        Box\u003CInteger> integerBox = new Box\u003CInteger>();\n        integerBox.add(new Integer(10));\n        Integer someInteger = integerBox.get(); \u002F\u002F no cast needed!\n        System.out.println(someInteger);\n    }\n}\n",[20,6476,6477,6493,6503,6525,6549,6569,6589,6607,6611],{"__ignoreMap":52},[56,6478,6479,6481,6483,6485,6487,6489,6491],{"class":58,"line":59},[56,6480,4147],{"class":999},[56,6482,4150],{"class":3436},[56,6484,1157],{"class":76},[56,6486,4155],{"class":3436},[56,6488,1157],{"class":76},[56,6490,6357],{"class":3436},[56,6492,2606],{"class":76},[56,6494,6495,6497,6499,6501],{"class":58,"line":86},[56,6496,4281],{"class":3436},[56,6498,4284],{"class":3436},[56,6500,6207],{"class":62},[56,6502,4290],{"class":76},[56,6504,6505,6507,6509,6511,6513,6515,6517,6519,6521,6523],{"class":58,"line":105},[56,6506,4295],{"class":3436},[56,6508,4298],{"class":3436},[56,6510,4301],{"class":3436},[56,6512,492],{"class":2666},[56,6514,4306],{"class":76},[56,6516,4309],{"class":3436},[56,6518,4312],{"class":76},[56,6520,4316],{"class":4315},[56,6522,4319],{"class":76},[56,6524,4290],{"class":76},[56,6526,6527,6529,6531,6533,6535,6537,6539,6541,6543,6545,6547],{"class":58,"line":120},[56,6528,6236],{"class":3436},[56,6530,3467],{"class":76},[56,6532,6020],{"class":3436},[56,6534,178],{"class":76},[56,6536,6239],{"class":174},[56,6538,3440],{"class":76},[56,6540,4334],{"class":2619},[56,6542,6066],{"class":3436},[56,6544,3467],{"class":76},[56,6546,6020],{"class":3436},[56,6548,4521],{"class":76},[56,6550,6551,6553,6555,6557,6559,6561,6563,6565,6567],{"class":58,"line":248},[56,6552,6252],{"class":174},[56,6554,1157],{"class":76},[56,6556,194],{"class":2666},[56,6558,4306],{"class":76},[56,6560,5338],{"class":2619},[56,6562,6263],{"class":2666},[56,6564,4306],{"class":76},[56,6566,6268],{"class":999},[56,6568,5349],{"class":76},[56,6570,6571,6573,6575,6577,6579,6581,6583,6586],{"class":58,"line":261},[56,6572,6279],{"class":3436},[56,6574,6282],{"class":174},[56,6576,3440],{"class":76},[56,6578,6293],{"class":174},[56,6580,1157],{"class":76},[56,6582,6298],{"class":2666},[56,6584,6585],{"class":76},"();",[56,6587,6588],{"class":130}," \u002F\u002F no cast needed!\n",[56,6590,6591,6593,6595,6597,6599,6601,6603,6605],{"class":58,"line":274},[56,6592,4644],{"class":174},[56,6594,1157],{"class":76},[56,6596,4649],{"class":174},[56,6598,1157],{"class":76},[56,6600,4654],{"class":2666},[56,6602,4306],{"class":76},[56,6604,6317],{"class":174},[56,6606,4359],{"class":76},[56,6608,6609],{"class":58,"line":279},[56,6610,4666],{"class":76},[56,6612,6613],{"class":58,"line":297},[56,6614,4672],{"class":76},[16,6616,6617,6618,6621,6622,6625],{},"In the previous example we needed a cast to Integer; in this one we don't. Even better, IDEs warn you before you even run it if you try to pass a type other than Integer to the add() method without you noticing 🙂 I'd say that's the most important part 🙂\nBy the way, with Java 7 the object creation expression got shorter, becoming ",[20,6619,6620],{},"Box\u003CInteger> integerBox = new Box\u003C>();"," — so there's no need to specify the type again in the part called the ",[4129,6623,6624],{},"diamond operator",".\nA question may have popped into your mind: what is this \"T\" thing, and can I use something else? That's where the Java Naming Convention — the Java naming standards — steps in.",[1121,6627,6628,6631,6634,6637,6640,6643],{},[1124,6629,6630],{},"E – Element (generally used in the Java Collection Framework)",[1124,6632,6633],{},"K – Key",[1124,6635,6636],{},"N – Number",[1124,6638,6639],{},"T – Type",[1124,6641,6642],{},"V – Value",[1124,6644,6645],{},"S,U,V etc. (these letters are picked when a 2nd, 3rd, 4th type is needed)",[16,6647,6648],{},"Without standards it would be hard to tell them apart — bless the standards 🙂",[16,6650,6651,6652,6655,6656,6660],{},"I hope it was useful for understanding the topic.\nTake it easy.\n",[4129,6653,6654],{},"Note:"," The examples at ",[1646,6657,6658],{"href":6658,"rel":6659},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002Ftutorial\u002Fjava\u002Fgenerics\u002Findex.html",[1650]," were used to improve clarity.",[1188,6662,6663],{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}",{"title":52,"searchDepth":86,"depth":86,"links":6665},[],"2011-07-08","Why generic types emerged in Java and how they protect us from ClassCastExceptions.",{},"\u002Fen\u002Fblog\u002Fgeneric-types",{"title":6012,"description":6667},"en\u002Fblog\u002Fgeneric-types",[6357,1758],"\u002Fblog\u002Fgeneric-types","bEy3mlhfyNEO7eX_7113BjZFAOmRO9MqnqYzQTGTf2c",{"id":6676,"title":6677,"body":6678,"date":6742,"description":6743,"extension":1203,"meta":6744,"navigation":231,"path":6745,"seo":6746,"stem":6747,"tags":6748,"translation":6749,"__hash__":6750},"pages_en\u002Fen\u002Fblog\u002Fjsf-model-view-controller-mvc.md","JSF Model-View-Controller (MVC)",{"type":8,"value":6679,"toc":6740},[6680,6691,6711,6720],[16,6681,6682,6683,6686,6687,6690],{},"One of the first concepts you run into with modern web applications is ",[1389,6684,6685],{},"MVC"," — ",[1389,6688,6689],{},"Model-View-Controller",". JSF also builds on the MVC pattern.",[1729,6692,6693,6699,6705],{},[1124,6694,6695,6698],{},[1389,6696,6697],{},"Model"," – our Java classes",[1124,6700,6701,6704],{},[1389,6702,6703],{},"View"," – our visual pages, the front end",[1124,6706,6707,6710],{},[1389,6708,6709],{},"Controller"," – can be seen as the servlet (Faces Servlet).",[16,6712,6713,6714,6719],{},"The following image from the ",[1646,6715,6718],{"href":6716,"rel":6717},"http:\u002F\u002Fjsfcompref.appspot.com\u002F",[1650],"JSF reference book"," illustrates it well.",[16,6721,6722,6727,6728,6730,6731,6733,6734,6736,6737,6739],{},[1646,6723,6725],{"href":6724},"\u002Fimages\u002Fjsf-model-view-controller-mvc-jsf-mvc-demonstration.png",[2168,6726],{"alt":52,"src":6724},"\nExpanding on the sample project in the picture: the ",[1389,6729,6697],{}," layer holds the Java Beans (User.java, Account.java, Item.java, ShoppingCart.java, etc.), the ",[1389,6732,6703],{}," layer holds our xhtml pages (showUser.xhtml, purchase.xhtml, editUser.xhtml, etc.) — the visual pages the end user sees — and underneath it all, the ",[4129,6735,3310],{}," we call the ",[1389,6738,6709],{}," manages the work. I won't dig deeper into Faces Servlet here; that's a topic for another post where we dive into JSF internals.\nIn short, in enterprise applications (JavaEE for Java) the layers are separated: the presentation layer (View) faces the end user and delegates work to the back end, the business logic lives in a separate layer (Model), and another layer (Controller) manages and coordinates them.\nMVC is a language-independent concept, and I believe anyone — whether they know Java or not — can grasp it from this illustration. 🙂 If not, get in touch.\nTake it easy.",{"title":52,"searchDepth":86,"depth":86,"links":6741},[],"2011-07-05","How JSF applies the MVC architecture: the split between model, view, and controller.",{},"\u002Fen\u002Fblog\u002Fjsf-model-view-controller-mvc",{"title":6677,"description":6743},"en\u002Fblog\u002Fjsf-model-view-controller-mvc",[1758,3044],"\u002Fblog\u002Fjsf-model-view-controller-mvc","C9mNiolsND6Og7eaTz2i-Dm2JRsmBddANPIr5UNJWdE",{"id":6752,"title":6753,"body":6754,"date":7071,"description":7072,"extension":1203,"meta":7073,"navigation":231,"path":7074,"seo":7075,"stem":7076,"tags":7077,"translation":7079,"__hash__":7080},"pages_en\u002Fen\u002Fblog\u002Fweb-service-client.md","Web Service Client",{"type":8,"value":6755,"toc":7069},[6756,6769,6777,6785,6810,6818,6832,7059,7066],[16,6757,6758,6759,6764,6765,6768],{},"In a ",[1646,6760,6763],{"href":6761,"rel":6762},"https:\u002F\u002Fwww.sukrucakmak.com\u002F2011\u002F06\u002Fglassfish-uzerinde-web-servis\u002F",[1650],"previous post"," I explained how to provide a web service on the GlassFish application server. But there are also clients that consume web services. In this post I'll try to explain how to create and run a client.\nTo create a ",[1389,6766,6767],{},"web service client"," in Eclipse, I first open a standard Java project. Since the previous project was named \"WebServiceGlassFish\", I named this one \"WebServiceGlassFishClient\" — you're of course free to pick any name.",[16,6770,6771,6776],{},[1646,6772,6774],{"href":6773},"\u002Fimages\u002Fweb-service-client-web-service-client-project.png",[2168,6775],{"alt":52,"src":6773},"\nAfter entering the project name, we click OK and create the project. Next comes creating the client: right-click the project and choose New > Web Service Client.",[16,6778,6779,6784],{},[1646,6780,6782],{"href":6781},"\u002Fimages\u002Fweb-service-client-web-service-client.png",[2168,6783],{"alt":52,"src":6781},"\nOn the next screen it asks for the client's address — that is, where the web service lives. I enter the address of the web service running on GlassFish as shown below; after a few seconds it detects it and the Next button and the others become active. We click OK.",[16,6786,6787,6792,6793,6798,6799,6802,6803,6805,6806,6809],{},[1646,6788,6790],{"href":6789},"\u002Fimages\u002Fweb-service-client-web-service-client-definition.png",[2168,6791],{"alt":52,"src":6789},"\nAfter these steps, Eclipse prepares a structure like the one below for us. The gist of it: it generates the classes that answer questions like where the web service is, which methods it has, what kind of parameters they take, and so on 🙂\n",[1646,6794,6796],{"href":6795},"\u002Fimages\u002Fweb-service-client-web-service-client-project-structure.png",[2168,6797],{"alt":52,"src":6795},"\nNow it's time to query the web service and get its response — for that I create a class named \"",[1389,6800,6801],{},"WebServiceTest","\" with a \"",[1389,6804,33],{},"\" method under the \"",[1389,6807,6808],{},"org.sukru.webservices.test","\" package.",[16,6811,6812,6817],{},[1646,6813,6815],{"href":6814},"\u002Fimages\u002Fweb-service-client-web-service-client-test-class.png",[2168,6816],{"alt":52,"src":6814},"\nAnd inside the generated class I do the following in order;",[1729,6819,6820,6823,6826,6829],{},[1124,6821,6822],{},"I create a \"service\" to communicate with the web service.",[1124,6824,6825],{},"I get a connection through the \"service\" and assign it to my HelloWorld object.",[1124,6827,6828],{},"Eclipse warns me that the method might throw an exception if something goes wrong, so I add it.",[1124,6830,6831],{},"Since the method I'll call on the web service — sayHello() — returns a String, I declare accordingly and invoke the web service.",[47,6833,6835],{"className":4139,"code":6834,"language":1758,"meta":52,"style":52},"package org.sukru.webservices.test;\nimport org.sukru.webservices.HelloWorld;\nimport org.sukru.webservices.HelloWorldService;\nimport org.sukru.webservices.HelloWorldServiceLocator;\npublic class WebServiceTest {\n    public static void main(String[] args) throws Exception {\n        HelloWorldService service = new HelloWorldServiceLocator();\n        HelloWorld port = service.getHelloWorldPort();\n        String cevap = port.sayHello(\"Melih Sakarya\");\n        System.out.println(\"Web Servisinin Cevabı: \"+ cevap );\n    }\n}\n",[20,6836,6837,6858,6879,6900,6921,6932,6960,6977,6996,7024,7051,7055],{"__ignoreMap":52},[56,6838,6839,6841,6843,6845,6847,6849,6852,6854,6856],{"class":58,"line":59},[56,6840,4147],{"class":999},[56,6842,4150],{"class":3436},[56,6844,1157],{"class":76},[56,6846,4155],{"class":3436},[56,6848,1157],{"class":76},[56,6850,6851],{"class":3436},"webservices",[56,6853,1157],{"class":76},[56,6855,4165],{"class":3436},[56,6857,2606],{"class":76},[56,6859,6860,6862,6864,6866,6868,6870,6872,6874,6877],{"class":58,"line":86},[56,6861,4172],{"class":999},[56,6863,4150],{"class":3436},[56,6865,1157],{"class":76},[56,6867,4155],{"class":3436},[56,6869,1157],{"class":76},[56,6871,6851],{"class":3436},[56,6873,1157],{"class":76},[56,6875,6876],{"class":3436},"HelloWorld",[56,6878,2606],{"class":76},[56,6880,6881,6883,6885,6887,6889,6891,6893,6895,6898],{"class":58,"line":105},[56,6882,4172],{"class":999},[56,6884,4150],{"class":3436},[56,6886,1157],{"class":76},[56,6888,4155],{"class":3436},[56,6890,1157],{"class":76},[56,6892,6851],{"class":3436},[56,6894,1157],{"class":76},[56,6896,6897],{"class":3436},"HelloWorldService",[56,6899,2606],{"class":76},[56,6901,6902,6904,6906,6908,6910,6912,6914,6916,6919],{"class":58,"line":120},[56,6903,4172],{"class":999},[56,6905,4150],{"class":3436},[56,6907,1157],{"class":76},[56,6909,4155],{"class":3436},[56,6911,1157],{"class":76},[56,6913,6851],{"class":3436},[56,6915,1157],{"class":76},[56,6917,6918],{"class":3436},"HelloWorldServiceLocator",[56,6920,2606],{"class":76},[56,6922,6923,6925,6927,6930],{"class":58,"line":248},[56,6924,4281],{"class":3436},[56,6926,4284],{"class":3436},[56,6928,6929],{"class":62}," WebServiceTest",[56,6931,4290],{"class":76},[56,6933,6934,6936,6938,6940,6942,6944,6946,6948,6950,6952,6955,6958],{"class":58,"line":261},[56,6935,4295],{"class":3436},[56,6937,4298],{"class":3436},[56,6939,4301],{"class":3436},[56,6941,492],{"class":2666},[56,6943,4306],{"class":76},[56,6945,4309],{"class":3436},[56,6947,4312],{"class":76},[56,6949,4316],{"class":4315},[56,6951,4319],{"class":76},[56,6953,6954],{"class":3436}," throws",[56,6956,6957],{"class":3436}," Exception",[56,6959,4290],{"class":76},[56,6961,6962,6965,6968,6970,6972,6975],{"class":58,"line":274},[56,6963,6964],{"class":3436},"        HelloWorldService",[56,6966,6967],{"class":174}," service ",[56,6969,3440],{"class":76},[56,6971,4334],{"class":2619},[56,6973,6974],{"class":2666}," HelloWorldServiceLocator",[56,6976,4585],{"class":76},[56,6978,6979,6982,6985,6987,6989,6991,6994],{"class":58,"line":279},[56,6980,6981],{"class":3436},"        HelloWorld",[56,6983,6984],{"class":174}," port ",[56,6986,3440],{"class":76},[56,6988,2505],{"class":174},[56,6990,1157],{"class":76},[56,6992,6993],{"class":2666},"getHelloWorldPort",[56,6995,4585],{"class":76},[56,6997,6998,7000,7003,7005,7008,7010,7013,7015,7017,7020,7022],{"class":58,"line":297},[56,6999,4619],{"class":3436},[56,7001,7002],{"class":174}," cevap ",[56,7004,3440],{"class":76},[56,7006,7007],{"class":174}," port",[56,7009,1157],{"class":76},[56,7011,7012],{"class":2666},"sayHello",[56,7014,4306],{"class":76},[56,7016,312],{"class":76},[56,7018,7019],{"class":66},"Melih Sakarya",[56,7021,312],{"class":76},[56,7023,4359],{"class":76},[56,7025,7026,7028,7030,7032,7034,7036,7038,7040,7043,7045,7047,7049],{"class":58,"line":318},[56,7027,4644],{"class":174},[56,7029,1157],{"class":76},[56,7031,4649],{"class":174},[56,7033,1157],{"class":76},[56,7035,4654],{"class":2666},[56,7037,4306],{"class":76},[56,7039,312],{"class":76},[56,7041,7042],{"class":66},"Web Servisinin Cevabı: ",[56,7044,312],{"class":76},[56,7046,5398],{"class":76},[56,7048,7002],{"class":174},[56,7050,4359],{"class":76},[56,7052,7053],{"class":58,"line":813},[56,7054,4666],{"class":76},[56,7056,7057],{"class":58,"line":1913},[56,7058,4672],{"class":76},[16,7060,7061,7062,7065],{},"When we right-click and choose Run As > Java Application, if we see the output ",[1389,7063,7064],{},"Web Servisinin Cevabı: Merhaba Melih Sakarya!",", we can celebrate 🙂\nTake it easy.",[1188,7067,7068],{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":52,"searchDepth":86,"depth":86,"links":7070},[],"2011-07-01","Steps for writing a web service client in Java.",{},"\u002Fen\u002Fblog\u002Fweb-service-client",{"title":6753,"description":7072},"en\u002Fblog\u002Fweb-service-client",[1758,7078],"web service","\u002Fblog\u002Fweb-service-client","navj5SAomZwbB6nPXpqNONOndUk50IVGrD1lNhmfKDQ",{"id":7082,"title":7083,"body":7084,"date":7640,"description":7641,"extension":1203,"meta":7642,"navigation":231,"path":7643,"seo":7644,"stem":7645,"tags":7646,"translation":7647,"__hash__":7648},"pages_en\u002Fen\u002Fblog\u002Fjava-system-properties.md","Java System Properties",{"type":8,"value":7085,"toc":7638},[7086,7096,7107,7338,7345,7351,7354,7361,7623,7626,7632,7635],[16,7087,7088,7089,7092,7093],{},"In Java we can get ",[1389,7090,7091],{},"system information"," through the keywords Java provides us.\n",[20,7094,7095],{},"Properties properties = System.getProperties();",[16,7097,7098,7099,7102,7103,7106],{},"With this expression we take the system properties into a \"properties\" object, then take the ",[1389,7100,7101],{},"entrySet"," into a ",[1389,7104,7105],{},"Set"," object with the expression below so we can iterate over it and look at each value one by one — because later we can look only at the ones that will be useful to us from time to time. You can see the example code below.",[47,7108,7110],{"className":4139,"code":7109,"language":1758,"meta":52,"style":52},"package org.sukru.system;\nimport java.util.Map.Entry;\nimport java.util.Properties;\nimport java.util.Set;\npublic class SystemProperties {\n    public static void main(String[] args) {\n        Properties properties = System.getProperties();\n        Set\u003CEntry\u003CObject, Object>> sets = properties.entrySet();\n        for (Entry\u003CObject, Object> entry : sets) {\n            System.out.println(entry.getKey());\n        }\n    }\n}\n",[20,7111,7112,7129,7151,7168,7184,7195,7217,7237,7271,7301,7326,7330,7334],{"__ignoreMap":52},[56,7113,7114,7116,7118,7120,7122,7124,7127],{"class":58,"line":59},[56,7115,4147],{"class":999},[56,7117,4150],{"class":3436},[56,7119,1157],{"class":76},[56,7121,4155],{"class":3436},[56,7123,1157],{"class":76},[56,7125,7126],{"class":3436},"system",[56,7128,2606],{"class":76},[56,7130,7131,7133,7135,7137,7139,7141,7144,7146,7149],{"class":58,"line":86},[56,7132,4172],{"class":999},[56,7134,4175],{"class":3436},[56,7136,1157],{"class":76},[56,7138,4180],{"class":3436},[56,7140,1157],{"class":76},[56,7142,7143],{"class":3436},"Map",[56,7145,1157],{"class":76},[56,7147,7148],{"class":3436},"Entry",[56,7150,2606],{"class":76},[56,7152,7153,7155,7157,7159,7161,7163,7166],{"class":58,"line":105},[56,7154,4172],{"class":999},[56,7156,4175],{"class":3436},[56,7158,1157],{"class":76},[56,7160,4180],{"class":3436},[56,7162,1157],{"class":76},[56,7164,7165],{"class":3436},"Properties",[56,7167,2606],{"class":76},[56,7169,7170,7172,7174,7176,7178,7180,7182],{"class":58,"line":120},[56,7171,4172],{"class":999},[56,7173,4175],{"class":3436},[56,7175,1157],{"class":76},[56,7177,4180],{"class":3436},[56,7179,1157],{"class":76},[56,7181,7105],{"class":3436},[56,7183,2606],{"class":76},[56,7185,7186,7188,7190,7193],{"class":58,"line":248},[56,7187,4281],{"class":3436},[56,7189,4284],{"class":3436},[56,7191,7192],{"class":62}," SystemProperties",[56,7194,4290],{"class":76},[56,7196,7197,7199,7201,7203,7205,7207,7209,7211,7213,7215],{"class":58,"line":261},[56,7198,4295],{"class":3436},[56,7200,4298],{"class":3436},[56,7202,4301],{"class":3436},[56,7204,492],{"class":2666},[56,7206,4306],{"class":76},[56,7208,4309],{"class":3436},[56,7210,4312],{"class":76},[56,7212,4316],{"class":4315},[56,7214,4319],{"class":76},[56,7216,4290],{"class":76},[56,7218,7219,7222,7225,7227,7230,7232,7235],{"class":58,"line":274},[56,7220,7221],{"class":3436},"        Properties",[56,7223,7224],{"class":174}," properties ",[56,7226,3440],{"class":76},[56,7228,7229],{"class":174}," System",[56,7231,1157],{"class":76},[56,7233,7234],{"class":2666},"getProperties",[56,7236,4585],{"class":76},[56,7238,7239,7242,7244,7246,7248,7250,7252,7254,7257,7260,7262,7265,7267,7269],{"class":58,"line":279},[56,7240,7241],{"class":3436},"        Set",[56,7243,3467],{"class":76},[56,7245,7148],{"class":3436},[56,7247,3467],{"class":76},[56,7249,6094],{"class":3436},[56,7251,4349],{"class":76},[56,7253,6076],{"class":3436},[56,7255,7256],{"class":76},">>",[56,7258,7259],{"class":174}," sets ",[56,7261,3440],{"class":76},[56,7263,7264],{"class":174}," properties",[56,7266,1157],{"class":76},[56,7268,7101],{"class":2666},[56,7270,4585],{"class":76},[56,7272,7273,7275,7277,7279,7281,7283,7285,7287,7289,7292,7294,7297,7299],{"class":58,"line":297},[56,7274,5485],{"class":2619},[56,7276,5360],{"class":76},[56,7278,7148],{"class":3436},[56,7280,3467],{"class":76},[56,7282,6094],{"class":3436},[56,7284,4349],{"class":76},[56,7286,6076],{"class":3436},[56,7288,178],{"class":76},[56,7290,7291],{"class":174}," entry ",[56,7293,3476],{"class":2619},[56,7295,7296],{"class":174}," sets",[56,7298,4319],{"class":76},[56,7300,4290],{"class":76},[56,7302,7303,7305,7307,7309,7311,7313,7315,7318,7320,7323],{"class":58,"line":318},[56,7304,5374],{"class":174},[56,7306,1157],{"class":76},[56,7308,4649],{"class":174},[56,7310,1157],{"class":76},[56,7312,4654],{"class":2666},[56,7314,4306],{"class":76},[56,7316,7317],{"class":174},"entry",[56,7319,1157],{"class":76},[56,7321,7322],{"class":2666},"getKey",[56,7324,7325],{"class":76},"());\n",[56,7327,7328],{"class":58,"line":813},[56,7329,5424],{"class":76},[56,7331,7332],{"class":58,"line":1913},[56,7333,4666],{"class":76},[56,7335,7336],{"class":58,"line":3654},[56,7337,4672],{"class":76},[16,7339,7340,7341,7344],{},"When we run this code we can reach all the property keys. In the output each line gives a different piece of information about the system — you'll usually understand at a glance what you can query. Example: ",[1389,7342,7343],{},"java.version"," gives you the Java version installed on the system. I've attached the output below.",[47,7346,7349],{"className":7347,"code":7348,"language":1226},[1224],"java.runtime.name\nsun.boot.library.path\njava.vm.version\njava.vm.vendor\njava.vendor.url\npath.separator\njava.vm.name\nfile.encoding.pkg\nsun.java.launcher\nuser.country\nsun.os.patch.level\njava.vm.specification.name\nuser.dir\njava.runtime.version\njava.awt.graphicsenv\njava.endorsed.dirs\nos.arch\njava.io.tmpdir\nline.separator\njava.vm.specification.vendor\nuser.variant\nos.name\nsun.jnu.encoding\njava.library.path\njava.specification.name\njava.class.version\nsun.management.compiler\nos.version\nuser.home\nuser.timezone\njava.awt.printerjob\nfile.encoding\njava.specification.version\njava.class.path\nuser.name\njava.vm.specification.version\nsun.java.command\njava.home\nsun.arch.data.model\nuser.language\njava.specification.vendor\nawt.toolkit\njava.vm.info\njava.version\njava.ext.dirs\nsun.boot.class.path\njava.vendor\nfile.separator\njava.vendor.url.bug\nsun.io.unicode.encoding\nsun.cpu.endian\nsun.desktop\nsun.cpu.isalist\n",[20,7350,7348],{"__ignoreMap":52},[16,7352,7353],{},"Still, let me query a few of them on my own machine — let's see what kind of environment I'm working in 🙂",[16,7355,7356,7357,7360],{},"We'll pass them as parameters to the ",[20,7358,7359],{},"System.getProperty(String property)"," expression and it will return the value.",[47,7362,7364],{"className":4139,"code":7363,"language":1758,"meta":52,"style":52},"package org.sukru.system;\npublic class SystemInfo {\n    public static void main(String[] args) {\n        System.out.println(\"Java version: \" + System.getProperty(\"java.version\"));\n        System.out.println(\"Java vendor: \" + System.getProperty(\"java.vendor\"));\n        System.out.println(\"Operating system name: \" + System.getProperty(\"os.name\"));\n        System.out.println(\"Operating system architecture: \" + System.getProperty(\"os.arch\"));\n        System.out.println(\"Operating system version: \" + System.getProperty(\"os.version\"));\n    }\n}\n",[20,7365,7366,7382,7393,7415,7455,7495,7535,7575,7615,7619],{"__ignoreMap":52},[56,7367,7368,7370,7372,7374,7376,7378,7380],{"class":58,"line":59},[56,7369,4147],{"class":999},[56,7371,4150],{"class":3436},[56,7373,1157],{"class":76},[56,7375,4155],{"class":3436},[56,7377,1157],{"class":76},[56,7379,7126],{"class":3436},[56,7381,2606],{"class":76},[56,7383,7384,7386,7388,7391],{"class":58,"line":86},[56,7385,4281],{"class":3436},[56,7387,4284],{"class":3436},[56,7389,7390],{"class":62}," SystemInfo",[56,7392,4290],{"class":76},[56,7394,7395,7397,7399,7401,7403,7405,7407,7409,7411,7413],{"class":58,"line":105},[56,7396,4295],{"class":3436},[56,7398,4298],{"class":3436},[56,7400,4301],{"class":3436},[56,7402,492],{"class":2666},[56,7404,4306],{"class":76},[56,7406,4309],{"class":3436},[56,7408,4312],{"class":76},[56,7410,4316],{"class":4315},[56,7412,4319],{"class":76},[56,7414,4290],{"class":76},[56,7416,7417,7419,7421,7423,7425,7427,7429,7431,7434,7436,7438,7440,7442,7445,7447,7449,7451,7453],{"class":58,"line":120},[56,7418,4644],{"class":174},[56,7420,1157],{"class":76},[56,7422,4649],{"class":174},[56,7424,1157],{"class":76},[56,7426,4654],{"class":2666},[56,7428,4306],{"class":76},[56,7430,312],{"class":76},[56,7432,7433],{"class":66},"Java version: ",[56,7435,312],{"class":76},[56,7437,5393],{"class":76},[56,7439,7229],{"class":174},[56,7441,1157],{"class":76},[56,7443,7444],{"class":2666},"getProperty",[56,7446,4306],{"class":76},[56,7448,312],{"class":76},[56,7450,7343],{"class":66},[56,7452,312],{"class":76},[56,7454,5349],{"class":76},[56,7456,7457,7459,7461,7463,7465,7467,7469,7471,7474,7476,7478,7480,7482,7484,7486,7488,7491,7493],{"class":58,"line":248},[56,7458,4644],{"class":174},[56,7460,1157],{"class":76},[56,7462,4649],{"class":174},[56,7464,1157],{"class":76},[56,7466,4654],{"class":2666},[56,7468,4306],{"class":76},[56,7470,312],{"class":76},[56,7472,7473],{"class":66},"Java vendor: ",[56,7475,312],{"class":76},[56,7477,5393],{"class":76},[56,7479,7229],{"class":174},[56,7481,1157],{"class":76},[56,7483,7444],{"class":2666},[56,7485,4306],{"class":76},[56,7487,312],{"class":76},[56,7489,7490],{"class":66},"java.vendor",[56,7492,312],{"class":76},[56,7494,5349],{"class":76},[56,7496,7497,7499,7501,7503,7505,7507,7509,7511,7514,7516,7518,7520,7522,7524,7526,7528,7531,7533],{"class":58,"line":261},[56,7498,4644],{"class":174},[56,7500,1157],{"class":76},[56,7502,4649],{"class":174},[56,7504,1157],{"class":76},[56,7506,4654],{"class":2666},[56,7508,4306],{"class":76},[56,7510,312],{"class":76},[56,7512,7513],{"class":66},"Operating system name: ",[56,7515,312],{"class":76},[56,7517,5393],{"class":76},[56,7519,7229],{"class":174},[56,7521,1157],{"class":76},[56,7523,7444],{"class":2666},[56,7525,4306],{"class":76},[56,7527,312],{"class":76},[56,7529,7530],{"class":66},"os.name",[56,7532,312],{"class":76},[56,7534,5349],{"class":76},[56,7536,7537,7539,7541,7543,7545,7547,7549,7551,7554,7556,7558,7560,7562,7564,7566,7568,7571,7573],{"class":58,"line":274},[56,7538,4644],{"class":174},[56,7540,1157],{"class":76},[56,7542,4649],{"class":174},[56,7544,1157],{"class":76},[56,7546,4654],{"class":2666},[56,7548,4306],{"class":76},[56,7550,312],{"class":76},[56,7552,7553],{"class":66},"Operating system architecture: ",[56,7555,312],{"class":76},[56,7557,5393],{"class":76},[56,7559,7229],{"class":174},[56,7561,1157],{"class":76},[56,7563,7444],{"class":2666},[56,7565,4306],{"class":76},[56,7567,312],{"class":76},[56,7569,7570],{"class":66},"os.arch",[56,7572,312],{"class":76},[56,7574,5349],{"class":76},[56,7576,7577,7579,7581,7583,7585,7587,7589,7591,7594,7596,7598,7600,7602,7604,7606,7608,7611,7613],{"class":58,"line":279},[56,7578,4644],{"class":174},[56,7580,1157],{"class":76},[56,7582,4649],{"class":174},[56,7584,1157],{"class":76},[56,7586,4654],{"class":2666},[56,7588,4306],{"class":76},[56,7590,312],{"class":76},[56,7592,7593],{"class":66},"Operating system version: ",[56,7595,312],{"class":76},[56,7597,5393],{"class":76},[56,7599,7229],{"class":174},[56,7601,1157],{"class":76},[56,7603,7444],{"class":2666},[56,7605,4306],{"class":76},[56,7607,312],{"class":76},[56,7609,7610],{"class":66},"os.version",[56,7612,312],{"class":76},[56,7614,5349],{"class":76},[56,7616,7617],{"class":58,"line":297},[56,7618,4666],{"class":76},[56,7620,7621],{"class":58,"line":318},[56,7622,4672],{"class":76},[16,7624,7625],{},"And the output, as seen;",[47,7627,7630],{"className":7628,"code":7629,"language":1226},[1224],"Java version: 1.6.0_25\nJava vendor: Sun Microsystems Inc.\nOperating system name: Windows 7\nOperating system architecture: amd64\nOperating system version: 6.1\n",[20,7631,7629],{"__ignoreMap":52},[16,7633,7634],{},"Of course, using these may vary by preference, but in the industry it's printed into the logs at a program's startup to summarize the software version and the environment it runs in.\nTake it easy.",[1188,7636,7637],{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":52,"searchDepth":86,"depth":86,"links":7639},[],"2011-06-30","Reading environment and system information at runtime with Java System Properties.",{},"\u002Fen\u002Fblog\u002Fjava-system-properties",{"title":7083,"description":7641},"en\u002Fblog\u002Fjava-system-properties",[1758],"\u002Fblog\u002Fjava-system-properties","xLF4QPGv-YXQaBErreYNjaJE2YKWvCeDMOqB00Hu_-U",{"id":7650,"title":3088,"body":7651,"date":7760,"description":7761,"extension":1203,"meta":7762,"navigation":231,"path":7763,"seo":7764,"stem":7765,"tags":7766,"translation":7767,"__hash__":7768},"pages_en\u002Fen\u002Fblog\u002Fjsf-life-cycle.md",{"type":8,"value":7652,"toc":7758},[7653,7667,7672,7679,7688,7708,7715,7723,7731,7739,7747,7755],[16,7654,7655,7656,5360,7661,7666],{},"In this post I'll try to explain what kind of life the ",[1646,7657,7660],{"href":7658,"rel":7659},"http:\u002F\u002Ftr.wikipedia.org\u002Fwiki\u002FJavaServer_Faces",[1650],"JSF framework",[1646,7662,7665],{"href":7663,"rel":7664},"http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FJavaServer_Faces",[1650],"JavaServer Faces Framework",") leads 🙂 Goes to bed late, wakes up late, and apparently drinks too... Joking aside, when I first started with JSF I was very curious about what it does between the moment we take an action on a web page and the moment it shows us the result, and how it responds to us — I even searched around and couldn't understand it, because there was hardly any resource explaining it clearly, and the ones that existed didn't speak my language (I was looking for a folksy explanation 🙂 ).",[2242,7668,7669],{},[16,7670,7671],{},"A JSF request is processed in 6 steps.",[16,7673,7674,7675,7678],{},"This image I took from the ",[1646,7676,6718],{"href":6716,"rel":7677},[1650]," illustrates it. I'll walk through each step.",[16,7680,7681,7687],{},[1646,7682,7684],{"href":7683},"\u002Fimages\u002Fjsf-life-cycle-jsf-life-cycle.png",[2168,7685],{"alt":7686,"src":7683},"jsf-life-cycle","\nNow let's list these steps;",[1729,7689,7690,7693,7696,7699,7702,7705],{},[1124,7691,7692],{},"Create or Restore View",[1124,7694,7695],{},"Apply Values from User",[1124,7697,7698],{},"Ensure Values are Valid",[1124,7700,7701],{},"Update Model with Valid Values",[1124,7703,7704],{},"Fetch a New View, If Necessary",[1124,7706,7707],{},"Render View",[16,7709,7710],{},[4129,7711,7712],{},[1389,7713,7714],{},"1. Create or Restore View",[16,7716,7717,7718],{},"The moment we open a JSF application, the components of the page we see are created. The user then performs a \"submit\" action — usually through a button, though other methods exist via Ajax.\n",[4129,7719,7720],{},[1389,7721,7722],{},"2. Apply Values from User",[16,7724,7725,7726],{},"The values entered by the user are picked up in this \"Apply Values\" phase.\n",[4129,7727,7728],{},[1389,7729,7730],{},"3. Ensure Values are Valid",[16,7732,7733,7734],{},"In this phase the values entered by the user are checked: whether they match the criteria, whether required fields are filled in, and so on. If everything is fine it moves to the next phase; otherwise it goes back to the first phase. For instance, we asked for only numbers in a field but the user typed letters, or we made a field required but the user submitted the form without providing a value…\n",[4129,7735,7736],{},[1389,7737,7738],{},"4. Update Model with Valid Values",[16,7740,7741,7742],{},"After the data has been validated in the previous phase, it's now the model's turn (bean, entity, etc.) to be updated — that is, the data obtained from the form is applied to it. Like the value entered in the \"name\" field of the form being assigned to the \"name\" field of the \"Student\" class…\n",[4129,7743,7744],{},[1389,7745,7746],{},"5. Fetch a New View, If Necessary",[16,7748,7749,7750],{},"If the form's actions result in a need for a new view, it creates that view.\n",[4129,7751,7752],{},[1389,7753,7754],{},"6. Render View",[16,7756,7757],{},"Finally, this phase runs to render the web page back to the user.\nBroadly speaking, that's the life JSF leads — seems reasonable so far, don't you think 🙂",{"title":52,"searchDepth":86,"depth":86,"links":7759},[],"2011-06-28","The 6 steps of the JSF life cycle: from processing the request to rendering the response.",{},"\u002Fen\u002Fblog\u002Fjsf-life-cycle",{"title":3088,"description":7761},"en\u002Fblog\u002Fjsf-life-cycle",[1758,3044],"\u002Fblog\u002Fjsf-life-cycle","fTqYIJ3DlG01aVCmH9Qp4xXw62pyMRLG4iOV2aOTVcA",{"id":7770,"title":7771,"body":7772,"date":7760,"description":8239,"extension":1203,"meta":8240,"navigation":231,"path":8241,"seo":8242,"stem":8243,"tags":8244,"translation":8246,"__hash__":8247},"pages_en\u002Fen\u002Fblog\u002Fweb-service-on-glassfish.md","Web Service on GlassFish",{"type":8,"value":7773,"toc":8237},[7774,7783,7802,7821,7831,7839,7853,7869,8038,8041,8160,8167,8175,8187,8200,8214,8222,8234],[16,7775,7776,7777,7782],{},"A web service (",[1646,7778,7781],{"href":7779,"rel":7780},"http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FWeb_service",[1650],"Web Service",") is one of the methods of communication between two devices.",[16,7784,7785,7786,7793,7794,7801],{},"There are multiple ways to develop a web service in Java. With the latest innovations, the \"",[1389,7787,7788],{},[1646,7789,7792],{"href":7790,"rel":7791},"http:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FJava_annotation",[1650],"Annotations","\" concept made this even easier — there's no need to generate a WSDL by hand; once you put the required annotation markers in place, the WSDL is generated on its own while the program runs.\n",[1646,7795,7798],{"href":7796,"rel":7797},"http:\u002F\u002Fglassfish.java.net\u002F",[1650],[1389,7799,7800],{},"GlassFish"," is, as you know, an open-source application server that's one of the cornerstones of JavaEE; its usage in the industry may be less than other servers, but it's one of the best known and — in my opinion — one of the easiest to use. Its admin console really simplifies management.\nNow, for the web service example we'll build on GlassFish, the ingredients we need are;",[1121,7803,7804,7815],{},[1124,7805,7806,7810],{},[1646,7807,7809],{"href":7796,"rel":7808},[1650],"GlassFish 3 application server",[1646,7811,7813],{"href":7812},"\u002Fimages\u002Fweb-service-on-glassfish-glassfish_logo.png",[2168,7814],{"alt":52,"src":7812},[1124,7816,7817],{},[1646,7818,7820],{"href":3195,"rel":7819},[1650],"Eclipse IDE for Java EE Developers",[16,7822,7823,7824,7827,7828,6156],{},"Let's proceed step by step. The web service we'll build will simply answer \"Merhaba {parameter}\" (\"Hello {parameter}\") to the \"String\" parameter it receives.\nLet's open a new \"",[1389,7825,7826],{},"Dynamic Web Project","\" in Eclipse. As seen in the picture, I named it \"",[1389,7829,7830],{},"WebServiceGlassFish",[16,7832,7833,7838],{},[1646,7834,7836],{"href":7835},"\u002Fimages\u002Fweb-service-on-glassfish-web-service-glassfish.png",[2168,7837],{"alt":52,"src":7835},"\nAfter clicking Next it asks where we write our source code; we click Next without touching anything, and the following screen appears — we specifically want it to generate web.xml.",[16,7840,7841,7846,7847,7849,7850,6156],{},[1646,7842,7844],{"href":7843},"\u002Fimages\u002Fweb-service-on-glassfish-web-xml.png",[2168,7845],{"alt":52,"src":7843},"\nTime to code — let's now create our class and the methods we want to write. I create a new Java class inside the project, name it \"",[1389,7848,6876],{},"\", and write its package as \"",[1389,7851,7852],{},"org.sukru.webservices",[16,7854,7855,7860,7861,7864,7865,7868],{},[1646,7856,7858],{"href":7857},"\u002Fimages\u002Fweb-service-on-glassfish-web-service-class.png",[2168,7859],{"alt":52,"src":7857},"\nFor a class to become a web service, the ",[1389,7862,7863],{},"@WebService()"," annotation is placed at the top of the class, and the ",[1389,7866,7867],{},"@WebMethod()"," annotation is placed on each method we want to expose as a web service method. OK, that's all you need to know — you may disperse 🙂 Joking aside, the example Java code is below…",[47,7870,7872],{"className":4139,"code":7871,"language":1758,"meta":52,"style":52},"package org.sukru.webservices;\nimport javax.jws.WebMethod;\nimport javax.jws.WebService;\n@WebService()\npublic class HelloWorld {\n    @WebMethod()\n    public String sayHello(String name) {\n        System.out.println(\"Merhaba \" + name);\n        return \"Merhaba\" + name + \"!\";\n    }\n}\n",[20,7873,7874,7890,7909,7926,7936,7947,7955,7976,8003,8030,8034],{"__ignoreMap":52},[56,7875,7876,7878,7880,7882,7884,7886,7888],{"class":58,"line":59},[56,7877,4147],{"class":999},[56,7879,4150],{"class":3436},[56,7881,1157],{"class":76},[56,7883,4155],{"class":3436},[56,7885,1157],{"class":76},[56,7887,6851],{"class":3436},[56,7889,2606],{"class":76},[56,7891,7892,7894,7897,7899,7902,7904,7907],{"class":58,"line":86},[56,7893,4172],{"class":999},[56,7895,7896],{"class":3436}," javax",[56,7898,1157],{"class":76},[56,7900,7901],{"class":3436},"jws",[56,7903,1157],{"class":76},[56,7905,7906],{"class":3436},"WebMethod",[56,7908,2606],{"class":76},[56,7910,7911,7913,7915,7917,7919,7921,7924],{"class":58,"line":105},[56,7912,4172],{"class":999},[56,7914,7896],{"class":3436},[56,7916,1157],{"class":76},[56,7918,7901],{"class":3436},[56,7920,1157],{"class":76},[56,7922,7923],{"class":3436},"WebService",[56,7925,2606],{"class":76},[56,7927,7928,7931,7933],{"class":58,"line":120},[56,7929,7930],{"class":76},"@",[56,7932,7923],{"class":3436},[56,7934,7935],{"class":76},"()\n",[56,7937,7938,7940,7942,7945],{"class":58,"line":248},[56,7939,4281],{"class":3436},[56,7941,4284],{"class":3436},[56,7943,7944],{"class":62}," HelloWorld",[56,7946,4290],{"class":76},[56,7948,7949,7951,7953],{"class":58,"line":261},[56,7950,5206],{"class":76},[56,7952,7906],{"class":3436},[56,7954,7935],{"class":76},[56,7956,7957,7959,7962,7965,7967,7969,7972,7974],{"class":58,"line":274},[56,7958,4295],{"class":3436},[56,7960,7961],{"class":3436}," String",[56,7963,7964],{"class":2666}," sayHello",[56,7966,4306],{"class":76},[56,7968,4309],{"class":3436},[56,7970,7971],{"class":4315}," name",[56,7973,4319],{"class":76},[56,7975,4290],{"class":76},[56,7977,7978,7980,7982,7984,7986,7988,7990,7992,7995,7997,7999,8001],{"class":58,"line":279},[56,7979,4644],{"class":174},[56,7981,1157],{"class":76},[56,7983,4649],{"class":174},[56,7985,1157],{"class":76},[56,7987,4654],{"class":2666},[56,7989,4306],{"class":76},[56,7991,312],{"class":76},[56,7993,7994],{"class":66},"Merhaba ",[56,7996,312],{"class":76},[56,7998,5393],{"class":76},[56,8000,7971],{"class":174},[56,8002,4359],{"class":76},[56,8004,8005,8007,8009,8012,8014,8016,8019,8021,8023,8026,8028],{"class":58,"line":297},[56,8006,6137],{"class":2619},[56,8008,77],{"class":76},[56,8010,8011],{"class":66},"Merhaba",[56,8013,312],{"class":76},[56,8015,5393],{"class":76},[56,8017,8018],{"class":174}," name ",[56,8020,5398],{"class":76},[56,8022,77],{"class":76},[56,8024,8025],{"class":66},"!",[56,8027,312],{"class":76},[56,8029,2606],{"class":76},[56,8031,8032],{"class":58,"line":318},[56,8033,4666],{"class":76},[56,8035,8036],{"class":58,"line":813},[56,8037,4672],{"class":76},[16,8039,8040],{},"An additional thing to do is to declare the servlet in web.xml — I write the following code inside the web.xml created at the beginning.",[47,8042,8044],{"className":2994,"code":8043,"language":2995,"meta":52,"style":52},"\u003Cservlet>\n    \u003Cdisplay-name>HelloWorld\u003C\u002Fdisplay-name>\n    \u003Cservlet-name>HelloWorld\u003C\u002Fservlet-name>\n    \u003Cservlet-class>org.sukru.webservices.HelloWorld\u003C\u002Fservlet-class>\n\u003C\u002Fservlet>\n\u003Cservlet-mapping>\n    \u003Cservlet-name>HelloWorld\u003C\u002Fservlet-name>\n    \u003Curl-pattern>\u002FHelloWorld\u003C\u002Furl-pattern>\n\u003C\u002Fservlet-mapping>\n",[20,8045,8046,8054,8070,8086,8103,8111,8119,8135,8152],{"__ignoreMap":52},[56,8047,8048,8050,8052],{"class":58,"line":59},[56,8049,3467],{"class":76},[56,8051,3294],{"class":3293},[56,8053,3297],{"class":76},[56,8055,8056,8058,8060,8062,8064,8066,8068],{"class":58,"line":86},[56,8057,3290],{"class":76},[56,8059,3571],{"class":3293},[56,8061,178],{"class":76},[56,8063,6876],{"class":174},[56,8065,3313],{"class":76},[56,8067,3571],{"class":3293},[56,8069,3297],{"class":76},[56,8071,8072,8074,8076,8078,8080,8082,8084],{"class":58,"line":105},[56,8073,3290],{"class":76},[56,8075,3305],{"class":3293},[56,8077,178],{"class":76},[56,8079,6876],{"class":174},[56,8081,3313],{"class":76},[56,8083,3305],{"class":3293},[56,8085,3297],{"class":76},[56,8087,8088,8090,8092,8094,8097,8099,8101],{"class":58,"line":120},[56,8089,3290],{"class":76},[56,8091,3324],{"class":3293},[56,8093,178],{"class":76},[56,8095,8096],{"class":174},"org.sukru.webservices.HelloWorld",[56,8098,3313],{"class":76},[56,8100,3324],{"class":3293},[56,8102,3297],{"class":76},[56,8104,8105,8107,8109],{"class":58,"line":248},[56,8106,3313],{"class":76},[56,8108,3294],{"class":3293},[56,8110,3297],{"class":76},[56,8112,8113,8115,8117],{"class":58,"line":261},[56,8114,3467],{"class":76},[56,8116,3374],{"class":3293},[56,8118,3297],{"class":76},[56,8120,8121,8123,8125,8127,8129,8131,8133],{"class":58,"line":274},[56,8122,3290],{"class":76},[56,8124,3305],{"class":3293},[56,8126,178],{"class":76},[56,8128,6876],{"class":174},[56,8130,3313],{"class":76},[56,8132,3305],{"class":3293},[56,8134,3297],{"class":76},[56,8136,8137,8139,8141,8143,8146,8148,8150],{"class":58,"line":279},[56,8138,3290],{"class":76},[56,8140,3399],{"class":3293},[56,8142,178],{"class":76},[56,8144,8145],{"class":174},"\u002FHelloWorld",[56,8147,3313],{"class":76},[56,8149,3399],{"class":3293},[56,8151,3297],{"class":76},[56,8153,8154,8156,8158],{"class":58,"line":297},[56,8155,3313],{"class":76},[56,8157,3374],{"class":3293},[56,8159,3297],{"class":76},[16,8161,8162,8163,8166],{},"With this, I've registered that I have a servlet named HelloWorld, its URL info and where its class lives — so the application server can recognize our application.\nNow we come to one of the important steps: deploying to GlassFish. We want to add a new server in Eclipse's Servers tab, but you won't find GlassFish in the standard list — that's why we follow Servers > New > Download Additional Adapters, select \"",[1389,8164,8165],{},"Oracle GlassFish Server Tools","\" from the list that comes up, and after a short install Eclipse wants to restart; we say restart.\nNow we can add it. There's an example below.",[16,8168,8169,8174],{},[1646,8170,8172],{"href":8171},"\u002Fimages\u002Fweb-service-on-glassfish-eclipse-server-glassfish.png",[2168,8173],{"alt":52,"src":8171},"\nWe enter the GlassFish username and password.",[16,8176,8177,8182,8183,8186],{},[1646,8178,8180],{"href":8179},"\u002Fimages\u002Fweb-service-on-glassfish-eclipse-server-glassfish-password.png",[2168,8181],{"alt":52,"src":8179},"\nAfter the password screen it asks which applications to deploy to the server; we select our web service application. If a GlassFish server is already defined in your Eclipse, you can also just right-click the server and use \"Add and Remove\" to deploy only the application.\nFinally we need to add GlassFish to the project's build path. Right-click the project, follow ",[4129,8184,8185],{},"Build Path > Configure Build-Path",", and add the server via Server Runtime.",[16,8188,8189,8194,8195,8199],{},[1646,8190,8192],{"href":8191},"\u002Fimages\u002Fweb-service-on-glassfish-web-service-properties-add-glassfish-library.png",[2168,8193],{"alt":52,"src":8191},"\nAfter that, start GlassFish and the application should now be running under GlassFish 🙂\nWe can see it in the GlassFish admin console (",[1646,8196,8197],{"href":8197,"rel":8198},"http:\u002F\u002Flocalhost:4848",[1650],") — if you haven't changed it; after logging into the server we can click the \"Applications\" menu on the left to see the installed applications.",[16,8201,8202,8207,8208,8210,8211,8213],{},[1646,8203,8205],{"href":8204},"\u002Fimages\u002Fweb-service-on-glassfish-glassfish-applications.png",[2168,8206],{"alt":52,"src":8204},"\nAs seen, the ",[1389,8209,7830],{}," project is deployed under GlassFish — by the way, when you first add it under the server from within Eclipse, the console also prints whether it was deployed or not.\nNow click \"launch\" on that screen, then append the ",[1389,8212,8145],{}," servlet name to the browser as shown below, and you'll get some information about the web service.",[16,8215,8216,8221],{},[1646,8217,8219],{"href":8218},"\u002Fimages\u002Fweb-service-on-glassfish-glassfish-web-service-servlet.png",[2168,8220],{"alt":52,"src":8218},"\nClicking the WSDL link gets you to the wsdl; mine looks like this.",[16,8223,8224,8229,8230,8233],{},[1646,8225,8227],{"href":8226},"\u002Fimages\u002Fweb-service-on-glassfish-glassfish-web-service-wsdl.png",[2168,8228],{"alt":52,"src":8226},"\nThe web service is now ready to use. God willing, we'll test this web service in another post 🙂 (I did test it — it's just the writing it up that takes effort ",[8231,8232],"d",{},")\nTake it easy.",[1188,8235,8236],{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}",{"title":52,"searchDepth":86,"depth":86,"links":8238},[],"Publishing a Java web service on the GlassFish application server.",{},"\u002Fen\u002Fblog\u002Fweb-service-on-glassfish",{"title":7771,"description":8239},"en\u002Fblog\u002Fweb-service-on-glassfish",[1329,8245,1758,7078],"glassfish","\u002Fblog\u002Fweb-service-on-glassfish","QEYatI0-8KO0MvcZk3wv9YQj_T6ii6LWARvwp68kDgI",{"id":8249,"title":8250,"body":8251,"date":8780,"description":8781,"extension":1203,"meta":8782,"navigation":231,"path":8783,"seo":8784,"stem":8785,"tags":8786,"translation":8787,"__hash__":8788},"pages_en\u002Fen\u002Fblog\u002Fapache-log4j.md","Apache log4j",{"type":8,"value":8252,"toc":8778},[8253,8264,8269,8272,8285,8292,8300,8313,8461,8464,8718,8721,8745,8752,8772,8775],[16,8254,8255,8259,8260,8263],{},[1646,8256,8250],{"href":8257,"rel":8258},"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F",[1650]," is a Java-based ",[1389,8261,8262],{},"logging"," mechanism. It's loved in the industry and handy. Integrating it into projects and using it is fairly easy.",[16,8265,8266],{},[2168,8267],{"alt":8250,"src":8268},"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F2.x\u002Fimages\u002Flogo.jpg",[16,8270,8271],{},"What we need to do;",[1121,8273,8274,8282],{},[1124,8275,8276,8281],{},[1646,8277,8280],{"href":8278,"rel":8279},"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F1.2\u002Fdownload.html",[1650],"download the jar file"," and add it to our project's libraries",[1124,8283,8284],{},"point the project build path at this jar.",[16,8286,8287,8288,8291],{},"After these steps we're ready to work with log4j. As an example I'll write a \"",[1389,8289,8290],{},"Student","\" class and try logging it. The application will be very basic — so basic that, although there are normally 2 ways of configuring log4j;",[1729,8293,8294,8297],{},[1124,8295,8296],{},"by preparing a property file",[1124,8298,8299],{},"by preparing an XML file",[16,8301,8302,8303,8308,8309,8312],{},"I'll bring log4j up without any file at all, using the \"",[4129,8304,8305],{},[1389,8306,8307],{},"configure()","\" method of the \"",[1389,8310,8311],{},"BasicConfigurator","\" class provided by log4j.",[47,8314,8316],{"className":4139,"code":8315,"language":1758,"meta":52,"style":52},"package org.sukru.log4j;\npublic class Student {\n    private Long studentNumber;\n    private String firstName;\n    private String lastName;\n    public Student(Long studentNumber, String firstName, String lastName) {\n        this.studentNumber = studentNumber;\n        this.firstName = firstName;\n        this.lastName = lastName;\n    }\n    \u002F\u002F getters and setters\n}\n",[20,8317,8318,8335,8346,8358,8369,8380,8409,8422,8435,8448,8452,8457],{"__ignoreMap":52},[56,8319,8320,8322,8324,8326,8328,8330,8333],{"class":58,"line":59},[56,8321,4147],{"class":999},[56,8323,4150],{"class":3436},[56,8325,1157],{"class":76},[56,8327,4155],{"class":3436},[56,8329,1157],{"class":76},[56,8331,8332],{"class":3436},"log4j",[56,8334,2606],{"class":76},[56,8336,8337,8339,8341,8344],{"class":58,"line":86},[56,8338,4281],{"class":3436},[56,8340,4284],{"class":3436},[56,8342,8343],{"class":62}," Student",[56,8345,4290],{"class":76},[56,8347,8348,8350,8353,8356],{"class":58,"line":105},[56,8349,6073],{"class":3436},[56,8351,8352],{"class":3436}," Long",[56,8354,8355],{"class":174}," studentNumber",[56,8357,2606],{"class":76},[56,8359,8360,8362,8364,8367],{"class":58,"line":120},[56,8361,6073],{"class":3436},[56,8363,7961],{"class":3436},[56,8365,8366],{"class":174}," firstName",[56,8368,2606],{"class":76},[56,8370,8371,8373,8375,8378],{"class":58,"line":248},[56,8372,6073],{"class":3436},[56,8374,7961],{"class":3436},[56,8376,8377],{"class":174}," lastName",[56,8379,2606],{"class":76},[56,8381,8382,8384,8386,8388,8391,8393,8395,8397,8399,8401,8403,8405,8407],{"class":58,"line":261},[56,8383,4295],{"class":3436},[56,8385,8343],{"class":2666},[56,8387,4306],{"class":76},[56,8389,8390],{"class":3436},"Long",[56,8392,8355],{"class":4315},[56,8394,4349],{"class":76},[56,8396,7961],{"class":3436},[56,8398,8366],{"class":4315},[56,8400,4349],{"class":76},[56,8402,7961],{"class":3436},[56,8404,8377],{"class":4315},[56,8406,4319],{"class":76},[56,8408,4290],{"class":76},[56,8410,8411,8413,8416,8418,8420],{"class":58,"line":274},[56,8412,6105],{"class":76},[56,8414,8415],{"class":174},"studentNumber ",[56,8417,3440],{"class":76},[56,8419,8355],{"class":174},[56,8421,2606],{"class":76},[56,8423,8424,8426,8429,8431,8433],{"class":58,"line":279},[56,8425,6105],{"class":76},[56,8427,8428],{"class":174},"firstName ",[56,8430,3440],{"class":76},[56,8432,8366],{"class":174},[56,8434,2606],{"class":76},[56,8436,8437,8439,8442,8444,8446],{"class":58,"line":297},[56,8438,6105],{"class":76},[56,8440,8441],{"class":174},"lastName ",[56,8443,3440],{"class":76},[56,8445,8377],{"class":174},[56,8447,2606],{"class":76},[56,8449,8450],{"class":58,"line":318},[56,8451,4666],{"class":76},[56,8453,8454],{"class":58,"line":813},[56,8455,8456],{"class":130},"    \u002F\u002F getters and setters\n",[56,8458,8459],{"class":58,"line":1913},[56,8460,4672],{"class":76},[16,8462,8463],{},"Let's also write the test class where we bring log4j up and use it.",[47,8465,8467],{"className":4139,"code":8466,"language":1758,"meta":52,"style":52},"package org.sukru.log4j;\nimport org.apache.log4j.BasicConfigurator;\nimport org.apache.log4j.Logger;\npublic class Log4jTest {\n    public static void main(String[] args) {\n        BasicConfigurator.configure(); \u002F\u002F let's bring log4j up.\n        Logger logger = Logger.getLogger(Student.class); \u002F\u002F let's specify which class to track.\n        logger.info(\"Initializing new Student…\");\n        Student student = new Student(100L, \"Yunus Emre\", \"Aslan\");\n        logger.info(\"new Student initialized: \"+student.getFirstName()+\" \"+student.getLastName());\n    }\n}\n",[20,8468,8469,8485,8506,8527,8538,8560,8575,8607,8628,8665,8710,8714],{"__ignoreMap":52},[56,8470,8471,8473,8475,8477,8479,8481,8483],{"class":58,"line":59},[56,8472,4147],{"class":999},[56,8474,4150],{"class":3436},[56,8476,1157],{"class":76},[56,8478,4155],{"class":3436},[56,8480,1157],{"class":76},[56,8482,8332],{"class":3436},[56,8484,2606],{"class":76},[56,8486,8487,8489,8491,8493,8496,8498,8500,8502,8504],{"class":58,"line":86},[56,8488,4172],{"class":999},[56,8490,4150],{"class":3436},[56,8492,1157],{"class":76},[56,8494,8495],{"class":3436},"apache",[56,8497,1157],{"class":76},[56,8499,8332],{"class":3436},[56,8501,1157],{"class":76},[56,8503,8311],{"class":3436},[56,8505,2606],{"class":76},[56,8507,8508,8510,8512,8514,8516,8518,8520,8522,8525],{"class":58,"line":105},[56,8509,4172],{"class":999},[56,8511,4150],{"class":3436},[56,8513,1157],{"class":76},[56,8515,8495],{"class":3436},[56,8517,1157],{"class":76},[56,8519,8332],{"class":3436},[56,8521,1157],{"class":76},[56,8523,8524],{"class":3436},"Logger",[56,8526,2606],{"class":76},[56,8528,8529,8531,8533,8536],{"class":58,"line":120},[56,8530,4281],{"class":3436},[56,8532,4284],{"class":3436},[56,8534,8535],{"class":62}," Log4jTest",[56,8537,4290],{"class":76},[56,8539,8540,8542,8544,8546,8548,8550,8552,8554,8556,8558],{"class":58,"line":248},[56,8541,4295],{"class":3436},[56,8543,4298],{"class":3436},[56,8545,4301],{"class":3436},[56,8547,492],{"class":2666},[56,8549,4306],{"class":76},[56,8551,4309],{"class":3436},[56,8553,4312],{"class":76},[56,8555,4316],{"class":4315},[56,8557,4319],{"class":76},[56,8559,4290],{"class":76},[56,8561,8562,8565,8567,8570,8572],{"class":58,"line":261},[56,8563,8564],{"class":174},"        BasicConfigurator",[56,8566,1157],{"class":76},[56,8568,8569],{"class":2666},"configure",[56,8571,6585],{"class":76},[56,8573,8574],{"class":130}," \u002F\u002F let's bring log4j up.\n",[56,8576,8577,8580,8583,8585,8588,8590,8593,8595,8597,8599,8601,8604],{"class":58,"line":274},[56,8578,8579],{"class":3436},"        Logger",[56,8581,8582],{"class":174}," logger ",[56,8584,3440],{"class":76},[56,8586,8587],{"class":174}," Logger",[56,8589,1157],{"class":76},[56,8591,8592],{"class":2666},"getLogger",[56,8594,4306],{"class":76},[56,8596,8290],{"class":174},[56,8598,1157],{"class":76},[56,8600,4612],{"class":174},[56,8602,8603],{"class":76},");",[56,8605,8606],{"class":130}," \u002F\u002F let's specify which class to track.\n",[56,8608,8609,8612,8614,8617,8619,8621,8624,8626],{"class":58,"line":279},[56,8610,8611],{"class":174},"        logger",[56,8613,1157],{"class":76},[56,8615,8616],{"class":2666},"info",[56,8618,4306],{"class":76},[56,8620,312],{"class":76},[56,8622,8623],{"class":66},"Initializing new Student…",[56,8625,312],{"class":76},[56,8627,4359],{"class":76},[56,8629,8630,8633,8636,8638,8640,8642,8644,8647,8649,8651,8653,8655,8657,8659,8661,8663],{"class":58,"line":297},[56,8631,8632],{"class":3436},"        Student",[56,8634,8635],{"class":174}," student ",[56,8637,3440],{"class":76},[56,8639,4334],{"class":2619},[56,8641,8343],{"class":2666},[56,8643,4306],{"class":76},[56,8645,8646],{"class":999},"100L",[56,8648,4349],{"class":76},[56,8650,77],{"class":76},[56,8652,4344],{"class":66},[56,8654,312],{"class":76},[56,8656,4349],{"class":76},[56,8658,77],{"class":76},[56,8660,4354],{"class":66},[56,8662,312],{"class":76},[56,8664,4359],{"class":76},[56,8666,8667,8669,8671,8673,8675,8677,8680,8682,8684,8687,8689,8692,8695,8697,8699,8701,8703,8705,8708],{"class":58,"line":318},[56,8668,8611],{"class":174},[56,8670,1157],{"class":76},[56,8672,8616],{"class":2666},[56,8674,4306],{"class":76},[56,8676,312],{"class":76},[56,8678,8679],{"class":66},"new Student initialized: ",[56,8681,312],{"class":76},[56,8683,5398],{"class":76},[56,8685,8686],{"class":174},"student",[56,8688,1157],{"class":76},[56,8690,8691],{"class":2666},"getFirstName",[56,8693,8694],{"class":76},"()+",[56,8696,312],{"class":76},[56,8698,77],{"class":76},[56,8700,5398],{"class":76},[56,8702,8686],{"class":174},[56,8704,1157],{"class":76},[56,8706,8707],{"class":2666},"getLastName",[56,8709,7325],{"class":76},[56,8711,8712],{"class":58,"line":813},[56,8713,4666],{"class":76},[56,8715,8716],{"class":58,"line":1913},[56,8717,4672],{"class":76},[16,8719,8720],{},"When we run this class the output will look like this.",[47,8722,8724],{"className":49,"code":8723,"language":51,"meta":52,"style":52},"0 [main] INFO org.sukru.log4j.Student  – Initializing a new Student…\n\n2 [main] INFO org.sukru.log4j.Student  – new Student initialized: Yunus Emre Aslan\n",[20,8725,8726,8734,8738],{"__ignoreMap":52},[56,8727,8728,8731],{"class":58,"line":59},[56,8729,8730],{"class":62},"0",[56,8732,8733],{"class":174}," [main] INFO org.sukru.log4j.Student  – Initializing a new Student…\n",[56,8735,8736],{"class":58,"line":86},[56,8737,232],{"emptyLinePlaceholder":231},[56,8739,8740,8742],{"class":58,"line":105},[56,8741,1048],{"class":62},[56,8743,8744],{"class":174}," [main] INFO org.sukru.log4j.Student  – new Student initialized: Yunus Emre Aslan\n",[16,8746,8747,8748,8751],{},"I used the \"",[1389,8749,8750],{},"info(Object message)","\" method for informational purposes, but depending on the need and the goal the following methods can be used;",[1121,8753,8754,8757,8760,8763,8766,8769],{},[1124,8755,8756],{},"fatal()",[1124,8758,8759],{},"error()",[1124,8761,8762],{},"warn()",[1124,8764,8765],{},"debug()",[1124,8767,8768],{},"trace()",[1124,8770,8771],{},"info()",[16,8773,8774],{},"I'll explain the other configuration methods in another post. I think this is enough for an introduction. Take it easy.",[1188,8776,8777],{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}",{"title":52,"searchDepth":86,"depth":86,"links":8779},[],"2011-06-27","An introduction to the Apache log4j logging framework in Java: core concepts, log levels, and usage.",{},"\u002Fen\u002Fblog\u002Fapache-log4j",{"title":8250,"description":8781},"en\u002Fblog\u002Fapache-log4j",[1758,8262],"\u002Fblog\u002Fapache-log4j","aYW68qc8iXAryRFh6blBRSUNp8qRVw4kFWoRYKhPsHs",{"id":8790,"title":8791,"body":8792,"date":8780,"description":9809,"extension":1203,"meta":9810,"navigation":231,"path":9811,"seo":9812,"stem":9813,"tags":9814,"translation":9815,"__hash__":9816},"pages_en\u002Fen\u002Fblog\u002Flog4j-configuration.md","Log4j Configuration",{"type":8,"value":8793,"toc":9807},[8794,8802,8816,8824,8830,8837,8844,8851,8863,8883,8886,8971,8982,9190,9216,9279,9282,9424,9427,9723,9726,9755,9768,9792,9804],[16,8795,8796,8797,8801],{},"Apache log4j, as I mentioned in ",[1646,8798,4012],{"href":8799,"rel":8800},"https:\u002F\u002Fwww.sukrucakmak.com\u002Fapache-log4j\u002F",[1650],", is a logging mechanism that gives us answers to these questions;",[1729,8803,8804,8807,8810,8813],{},[1124,8805,8806],{},"Who?",[1124,8808,8809],{},"What?",[1124,8811,8812],{},"When?",[1124,8814,8815],{},"Where?",[16,8817,8818,8819,4349],{},"Now it's time to talk a bit about the basic concepts we need to know.\n**Log Levels (LEVELS)**Although ",[1646,8820,8823],{"href":8821,"rel":8822},"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F1.2\u002Fapidocs\u002Forg\u002Fapache\u002Flog4j\u002FLevel.html#TRACE",[1650],"TRACE",[16,8825,8826,4349],{},[1646,8827,2883],{"href":8828,"rel":8829},"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F1.2\u002Fapidocs\u002Forg\u002Fapache\u002Flog4j\u002FLevel.html#DEBUG",[1650],[16,8831,8832,4349],{},[1646,8833,8836],{"href":8834,"rel":8835},"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F1.2\u002Fapidocs\u002Forg\u002Fapache\u002Flog4j\u002FLevel.html#INFO",[1650],"INFO",[16,8838,8839,4349],{},[1646,8840,8843],{"href":8841,"rel":8842},"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F1.2\u002Fapidocs\u002Forg\u002Fapache\u002Flog4j\u002FLevel.html#WARN",[1650],"WARN",[16,8845,8846,4349],{},[1646,8847,8850],{"href":8848,"rel":8849},"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F1.2\u002Fapidocs\u002Forg\u002Fapache\u002Flog4j\u002FLevel.html#ERROR",[1650],"ERROR",[16,8852,8853,8858,8859,8862],{},[1646,8854,8857],{"href":8855,"rel":8856},"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F1.2\u002Fapidocs\u002Forg\u002Fapache\u002Flog4j\u002FLevel.html#FATAL",[1650],"FATAL"," exist, you can also write your own log level — but let me note that it's not recommended.\nThe ordering between levels is as follows: **",[20,8860,8861],{},"DEBUG \u003C INFO \u003C WARN \u003C ERROR \u003C FATAL",".**We'll understand better what this ordering is good for in the example below.\n**Log Writers (APPENDERS)**It's possible to write logs to various targets; a few are listed below. I mostly write to file and the console.",[1121,8864,8865,8868,8871,8874,8877,8880],{},[1124,8866,8867],{},"FileAppender",[1124,8869,8870],{},"ConsoleAppender",[1124,8872,8873],{},"SocketAppender",[1124,8875,8876],{},"SyslogAppender",[1124,8878,8879],{},"NTEventLogAppender",[1124,8881,8882],{},"SMTPAppender",[16,8884,8885],{},"**Layouts (LAYOUTS)**Contains info about how the log will look; where the time goes, where the method name goes, etc.",[604,8887,8888,8898],{},[607,8889,8890],{},[610,8891,8892,8895],{},[613,8893,8894],{},"Abbreviation",[613,8896,8897],{},"Meaning",[623,8899,8900,8908,8916,8924,8932,8940,8947,8955,8963],{},[610,8901,8902,8905],{},[628,8903,8904],{},"%r",[628,8906,8907],{},"How much time was spent until logging started.",[610,8909,8910,8913],{},[628,8911,8912],{},"%t",[628,8914,8915],{},"Name of the thread that produced the log event.",[610,8917,8918,8921],{},[628,8919,8920],{},"%p",[628,8922,8923],{},"The log's level.",[610,8925,8926,8929],{},[628,8927,8928],{},"%c",[628,8930,8931],{},"The log's category — i.e. the package info of the class that produced it, etc.",[610,8933,8934,8937],{},[628,8935,8936],{},"%x",[628,8938,8939],{},"For some controls of the log.",[610,8941,8942,8945],{},[628,8943,8944],{},"%m",[628,8946,309],{},[610,8948,8949,8952],{},[628,8950,8951],{},"%n",[628,8953,8954],{},"To move to a new line.",[610,8956,8957,8960],{},[628,8958,8959],{},"%L",[628,8961,8962],{},"Info about which line it was on.",[610,8964,8965,8968],{},[628,8966,8967],{},"%d",[628,8969,8970],{},"The time the log was produced.",[16,8972,8973,8974,8977,8978,8981],{},"Now, with all this theoretical knowledge, I'll build a working application. I create a folder named \"",[1389,8975,8976],{},"config","\" under my project and prepare the following file named \"",[1389,8979,8980],{},"log4j.xml","\" inside it.",[47,8983,8985],{"className":2994,"code":8984,"language":2995,"meta":52,"style":52},"\u003C?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\u003C!DOCTYPE log4j:configuration PUBLIC \"-\u002F\u002FLOGGER\" \"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F1.2\u002Fapidocs\u002Forg\u002Fapache\u002Flog4j\u002Fxml\u002Fdoc-files\u002Flog4j.dtd\">\n\u003Clog4j:configuration>\n \u003Cappender name=\"stdout\" class=\"org.apache.log4j.ConsoleAppender\">\n    \u003Clayout class=\"org.apache.log4j.PatternLayout\">\n        \u003Cparam name=\"ConversionPattern\" value=\"%d [%t] %5p %c{1}:%L – %m %n\" \u002F>\n    \u003C\u002Flayout>\n  \u003C\u002Fappender>\n \u003Croot>\n   \u003Cappender-ref ref=\"stdout\" \u002F>\n \u003C\u002Froot>\n\u003C\u002Flog4j:configuration>\n",[20,8986,8987,9015,9027,9040,9071,9091,9123,9131,9139,9148,9169,9178],{"__ignoreMap":52},[56,8988,8989,8991,8993,8995,8997,8999,9001,9003,9005,9007,9009,9011,9013],{"class":58,"line":59},[56,8990,3431],{"class":76},[56,8992,2995],{"class":3293},[56,8994,3437],{"class":3436},[56,8996,3440],{"class":76},[56,8998,312],{"class":76},[56,9000,3445],{"class":66},[56,9002,312],{"class":76},[56,9004,3450],{"class":3436},[56,9006,3440],{"class":76},[56,9008,312],{"class":76},[56,9010,3457],{"class":66},[56,9012,312],{"class":76},[56,9014,3462],{"class":76},[56,9016,9017,9019,9021,9024],{"class":58,"line":86},[56,9018,3775],{"class":76},[56,9020,3778],{"class":999},[56,9022,9023],{"class":174}," log4j:configuration",[56,9025,9026],{"class":76}," PUBLIC \"-\u002F\u002FLOGGER\" \"http:\u002F\u002Flogging.apache.org\u002Flog4j\u002F1.2\u002Fapidocs\u002Forg\u002Fapache\u002Flog4j\u002Fxml\u002Fdoc-files\u002Flog4j.dtd\">\n",[56,9028,9029,9031,9033,9035,9038],{"class":58,"line":105},[56,9030,3467],{"class":76},[56,9032,8332],{"class":3293},[56,9034,3476],{"class":76},[56,9036,9037],{"class":3293},"configuration",[56,9039,3297],{"class":76},[56,9041,9042,9044,9047,9049,9051,9053,9056,9058,9060,9062,9064,9067,9069],{"class":58,"line":120},[56,9043,168],{"class":76},[56,9045,9046],{"class":3293},"appender",[56,9048,7971],{"class":3436},[56,9050,3440],{"class":76},[56,9052,312],{"class":76},[56,9054,9055],{"class":66},"stdout",[56,9057,312],{"class":76},[56,9059,4284],{"class":3436},[56,9061,3440],{"class":76},[56,9063,312],{"class":76},[56,9065,9066],{"class":66},"org.apache.log4j.ConsoleAppender",[56,9068,312],{"class":76},[56,9070,3297],{"class":76},[56,9072,9073,9075,9078,9080,9082,9084,9087,9089],{"class":58,"line":248},[56,9074,3290],{"class":76},[56,9076,9077],{"class":3293},"layout",[56,9079,4284],{"class":3436},[56,9081,3440],{"class":76},[56,9083,312],{"class":76},[56,9085,9086],{"class":66},"org.apache.log4j.PatternLayout",[56,9088,312],{"class":76},[56,9090,3297],{"class":76},[56,9092,9093,9095,9098,9100,9102,9104,9107,9109,9112,9114,9116,9119,9121],{"class":58,"line":261},[56,9094,3302],{"class":76},[56,9096,9097],{"class":3293},"param",[56,9099,7971],{"class":3436},[56,9101,3440],{"class":76},[56,9103,312],{"class":76},[56,9105,9106],{"class":66},"ConversionPattern",[56,9108,312],{"class":76},[56,9110,9111],{"class":3436}," value",[56,9113,3440],{"class":76},[56,9115,312],{"class":76},[56,9117,9118],{"class":66},"%d [%t] %5p %c{1}:%L – %m %n",[56,9120,312],{"class":76},[56,9122,3896],{"class":76},[56,9124,9125,9127,9129],{"class":58,"line":274},[56,9126,3358],{"class":76},[56,9128,9077],{"class":3293},[56,9130,3297],{"class":76},[56,9132,9133,9135,9137],{"class":58,"line":279},[56,9134,4112],{"class":76},[56,9136,9046],{"class":3293},[56,9138,3297],{"class":76},[56,9140,9141,9143,9146],{"class":58,"line":297},[56,9142,168],{"class":76},[56,9144,9145],{"class":3293},"root",[56,9147,3297],{"class":76},[56,9149,9150,9153,9156,9159,9161,9163,9165,9167],{"class":58,"line":318},[56,9151,9152],{"class":76},"   \u003C",[56,9154,9155],{"class":3293},"appender-ref",[56,9157,9158],{"class":3436}," ref",[56,9160,3440],{"class":76},[56,9162,312],{"class":76},[56,9164,9055],{"class":66},[56,9166,312],{"class":76},[56,9168,3896],{"class":76},[56,9170,9171,9174,9176],{"class":58,"line":813},[56,9172,9173],{"class":76}," \u003C\u002F",[56,9175,9145],{"class":3293},[56,9177,3297],{"class":76},[56,9179,9180,9182,9184,9186,9188],{"class":58,"line":1913},[56,9181,3313],{"class":76},[56,9183,8332],{"class":3293},[56,9185,3476],{"class":76},[56,9187,9037],{"class":3293},[56,9189,3297],{"class":76},[16,9191,9192,9193,9195,9196,9198,9199,9201,9202,9205,9206,9208,9209,9211,9212,9215],{},"Now let me explain the xml above a bit; when the program starts reading this xml it first looks under ",[1389,9194,9145],{}," and searches for an ",[1389,9197,9046],{}," so it can write the log there. Ours has one named ",[1389,9200,9055],{},"; it goes and finds it among the ",[1389,9203,9204],{},"appenders",", understands ours is a ",[1389,9207,8870],{}," — one that writes to the console — and writes to the ",[1389,9210,9046],{}," according to its ",[1389,9213,9214],{},"pattern",". That's the story 🙂\nNow let's unpack the pattern a bit;",[1121,9217,9218,9229,9242,9250,9258,9265,9272],{},[1124,9219,9220,9224,9225,9228],{},[4129,9221,9222],{},[1389,9223,8967],{}," – Show the run time (I didn't give any formatter but you can write any ",[4129,9226,9227],{},"date format pattern"," you like inside curly braces)",[1124,9230,9231,9237,9238,9241],{},[4129,9232,9233],{},[1389,9234,9235],{},[56,9236,8912],{}," – Show which thread is running, wrapped in \"",[56,9239,9240],{},"\" and \"","\" characters.",[1124,9243,9244,9249],{},[4129,9245,9246],{},[1389,9247,9248],{},"%5p"," – Show the log's level.",[1124,9251,9252,9257],{},[4129,9253,9254],{},[1389,9255,9256],{},"%c{1}"," – Show the log's category up to level 1. (Also try removing it 🙂 )",[1124,9259,9260,9264],{},[4129,9261,9262],{},[1389,9263,8959],{}," – Show which line ran.",[1124,9266,9267,9271],{},[4129,9268,9269],{},[1389,9270,8944],{}," – Write the message.",[1124,9273,9274,9278],{},[4129,9275,9276],{},[1389,9277,8951],{}," – Write the next message on the line below.",[16,9280,9281],{},"Now let's use log4j. First let's write a class.",[47,9283,9285],{"className":4139,"code":9284,"language":1758,"meta":52,"style":52},"package org.sukru.log4j;\npublic class Student {\n private Long studentNumber;\n private String firstName;\n private String lastName;\n public Student(Long studentNumber, String firstName, String lastName) {\n   this.studentNumber = studentNumber;\n   this.firstName = firstName;\n   this.lastName = lastName;\n }\n  \u002F\u002F getters and setters\n}\n",[20,9286,9287,9303,9313,9324,9334,9344,9373,9386,9398,9410,9415,9420],{"__ignoreMap":52},[56,9288,9289,9291,9293,9295,9297,9299,9301],{"class":58,"line":59},[56,9290,4147],{"class":999},[56,9292,4150],{"class":3436},[56,9294,1157],{"class":76},[56,9296,4155],{"class":3436},[56,9298,1157],{"class":76},[56,9300,8332],{"class":3436},[56,9302,2606],{"class":76},[56,9304,9305,9307,9309,9311],{"class":58,"line":86},[56,9306,4281],{"class":3436},[56,9308,4284],{"class":3436},[56,9310,8343],{"class":62},[56,9312,4290],{"class":76},[56,9314,9315,9318,9320,9322],{"class":58,"line":105},[56,9316,9317],{"class":3436}," private",[56,9319,8352],{"class":3436},[56,9321,8355],{"class":174},[56,9323,2606],{"class":76},[56,9325,9326,9328,9330,9332],{"class":58,"line":120},[56,9327,9317],{"class":3436},[56,9329,7961],{"class":3436},[56,9331,8366],{"class":174},[56,9333,2606],{"class":76},[56,9335,9336,9338,9340,9342],{"class":58,"line":248},[56,9337,9317],{"class":3436},[56,9339,7961],{"class":3436},[56,9341,8377],{"class":174},[56,9343,2606],{"class":76},[56,9345,9346,9349,9351,9353,9355,9357,9359,9361,9363,9365,9367,9369,9371],{"class":58,"line":261},[56,9347,9348],{"class":3436}," public",[56,9350,8343],{"class":2666},[56,9352,4306],{"class":76},[56,9354,8390],{"class":3436},[56,9356,8355],{"class":4315},[56,9358,4349],{"class":76},[56,9360,7961],{"class":3436},[56,9362,8366],{"class":4315},[56,9364,4349],{"class":76},[56,9366,7961],{"class":3436},[56,9368,8377],{"class":4315},[56,9370,4319],{"class":76},[56,9372,4290],{"class":76},[56,9374,9375,9378,9380,9382,9384],{"class":58,"line":274},[56,9376,9377],{"class":76},"   this.",[56,9379,8415],{"class":174},[56,9381,3440],{"class":76},[56,9383,8355],{"class":174},[56,9385,2606],{"class":76},[56,9387,9388,9390,9392,9394,9396],{"class":58,"line":279},[56,9389,9377],{"class":76},[56,9391,8428],{"class":174},[56,9393,3440],{"class":76},[56,9395,8366],{"class":174},[56,9397,2606],{"class":76},[56,9399,9400,9402,9404,9406,9408],{"class":58,"line":297},[56,9401,9377],{"class":76},[56,9403,8441],{"class":174},[56,9405,3440],{"class":76},[56,9407,8377],{"class":174},[56,9409,2606],{"class":76},[56,9411,9412],{"class":58,"line":318},[56,9413,9414],{"class":76}," }\n",[56,9416,9417],{"class":58,"line":813},[56,9418,9419],{"class":130},"  \u002F\u002F getters and setters\n",[56,9421,9422],{"class":58,"line":1913},[56,9423,4672],{"class":76},[16,9425,9426],{},"Our test class for Log4j.",[47,9428,9430],{"className":4139,"code":9429,"language":1758,"meta":52,"style":52},"package org.sukru.log4j;\nimport org.apache.log4j.Logger;\nimport org.apache.log4j.xml.DOMConfigurator;\npublic class Log4jTest {\n  private static Logger logger;\n  public static void main(String[] args) {\n    configureLog4j();   \u002F\u002F I wrote this method to bring log4j up.\n    logger.info(\"Initializing a new Student…\");\n    Student student = new Student(100L, \"Tuncay\", \"Uzun\");\n    logger.info(\"new Student initialized: \"+student.getFirstName()+\" \"+student.getLastName());\n  }\n  private static void configureLog4j() {\n    DOMConfigurator.configureAndWatch(\"config\u002Flog4j.xml\");   \u002F\u002F we give the location of the log4j configuration file in the project.\n    logger = Logger.getLogger(Log4jTest.class);\n  }\n}\n",[20,9431,9432,9448,9468,9493,9503,9517,9540,9550,9570,9607,9647,9652,9667,9691,9715,9719],{"__ignoreMap":52},[56,9433,9434,9436,9438,9440,9442,9444,9446],{"class":58,"line":59},[56,9435,4147],{"class":999},[56,9437,4150],{"class":3436},[56,9439,1157],{"class":76},[56,9441,4155],{"class":3436},[56,9443,1157],{"class":76},[56,9445,8332],{"class":3436},[56,9447,2606],{"class":76},[56,9449,9450,9452,9454,9456,9458,9460,9462,9464,9466],{"class":58,"line":86},[56,9451,4172],{"class":999},[56,9453,4150],{"class":3436},[56,9455,1157],{"class":76},[56,9457,8495],{"class":3436},[56,9459,1157],{"class":76},[56,9461,8332],{"class":3436},[56,9463,1157],{"class":76},[56,9465,8524],{"class":3436},[56,9467,2606],{"class":76},[56,9469,9470,9472,9474,9476,9478,9480,9482,9484,9486,9488,9491],{"class":58,"line":105},[56,9471,4172],{"class":999},[56,9473,4150],{"class":3436},[56,9475,1157],{"class":76},[56,9477,8495],{"class":3436},[56,9479,1157],{"class":76},[56,9481,8332],{"class":3436},[56,9483,1157],{"class":76},[56,9485,2995],{"class":3436},[56,9487,1157],{"class":76},[56,9489,9490],{"class":3436},"DOMConfigurator",[56,9492,2606],{"class":76},[56,9494,9495,9497,9499,9501],{"class":58,"line":120},[56,9496,4281],{"class":3436},[56,9498,4284],{"class":3436},[56,9500,8535],{"class":62},[56,9502,4290],{"class":76},[56,9504,9505,9508,9510,9512,9515],{"class":58,"line":248},[56,9506,9507],{"class":3436},"  private",[56,9509,4298],{"class":3436},[56,9511,8587],{"class":3436},[56,9513,9514],{"class":174}," logger",[56,9516,2606],{"class":76},[56,9518,9519,9522,9524,9526,9528,9530,9532,9534,9536,9538],{"class":58,"line":261},[56,9520,9521],{"class":3436},"  public",[56,9523,4298],{"class":3436},[56,9525,4301],{"class":3436},[56,9527,492],{"class":2666},[56,9529,4306],{"class":76},[56,9531,4309],{"class":3436},[56,9533,4312],{"class":76},[56,9535,4316],{"class":4315},[56,9537,4319],{"class":76},[56,9539,4290],{"class":76},[56,9541,9542,9545,9547],{"class":58,"line":274},[56,9543,9544],{"class":2666},"    configureLog4j",[56,9546,6585],{"class":76},[56,9548,9549],{"class":130},"   \u002F\u002F I wrote this method to bring log4j up.\n",[56,9551,9552,9555,9557,9559,9561,9563,9566,9568],{"class":58,"line":279},[56,9553,9554],{"class":174},"    logger",[56,9556,1157],{"class":76},[56,9558,8616],{"class":2666},[56,9560,4306],{"class":76},[56,9562,312],{"class":76},[56,9564,9565],{"class":66},"Initializing a new Student…",[56,9567,312],{"class":76},[56,9569,4359],{"class":76},[56,9571,9572,9575,9577,9579,9581,9583,9585,9587,9589,9591,9594,9596,9598,9600,9603,9605],{"class":58,"line":297},[56,9573,9574],{"class":3436},"    Student",[56,9576,8635],{"class":174},[56,9578,3440],{"class":76},[56,9580,4334],{"class":2619},[56,9582,8343],{"class":2666},[56,9584,4306],{"class":76},[56,9586,8646],{"class":999},[56,9588,4349],{"class":76},[56,9590,77],{"class":76},[56,9592,9593],{"class":66},"Tuncay",[56,9595,312],{"class":76},[56,9597,4349],{"class":76},[56,9599,77],{"class":76},[56,9601,9602],{"class":66},"Uzun",[56,9604,312],{"class":76},[56,9606,4359],{"class":76},[56,9608,9609,9611,9613,9615,9617,9619,9621,9623,9625,9627,9629,9631,9633,9635,9637,9639,9641,9643,9645],{"class":58,"line":318},[56,9610,9554],{"class":174},[56,9612,1157],{"class":76},[56,9614,8616],{"class":2666},[56,9616,4306],{"class":76},[56,9618,312],{"class":76},[56,9620,8679],{"class":66},[56,9622,312],{"class":76},[56,9624,5398],{"class":76},[56,9626,8686],{"class":174},[56,9628,1157],{"class":76},[56,9630,8691],{"class":2666},[56,9632,8694],{"class":76},[56,9634,312],{"class":76},[56,9636,77],{"class":76},[56,9638,5398],{"class":76},[56,9640,8686],{"class":174},[56,9642,1157],{"class":76},[56,9644,8707],{"class":2666},[56,9646,7325],{"class":76},[56,9648,9649],{"class":58,"line":813},[56,9650,9651],{"class":76},"  }\n",[56,9653,9654,9656,9658,9660,9663,9665],{"class":58,"line":1913},[56,9655,9507],{"class":3436},[56,9657,4298],{"class":3436},[56,9659,4301],{"class":3436},[56,9661,9662],{"class":2666}," configureLog4j",[56,9664,6130],{"class":76},[56,9666,4290],{"class":76},[56,9668,9669,9672,9674,9677,9679,9681,9684,9686,9688],{"class":58,"line":3654},[56,9670,9671],{"class":174},"    DOMConfigurator",[56,9673,1157],{"class":76},[56,9675,9676],{"class":2666},"configureAndWatch",[56,9678,4306],{"class":76},[56,9680,312],{"class":76},[56,9682,9683],{"class":66},"config\u002Flog4j.xml",[56,9685,312],{"class":76},[56,9687,8603],{"class":76},[56,9689,9690],{"class":130},"   \u002F\u002F we give the location of the log4j configuration file in the project.\n",[56,9692,9693,9696,9698,9700,9702,9704,9706,9709,9711,9713],{"class":58,"line":3659},[56,9694,9695],{"class":174},"    logger ",[56,9697,3440],{"class":76},[56,9699,8587],{"class":174},[56,9701,1157],{"class":76},[56,9703,8592],{"class":2666},[56,9705,4306],{"class":76},[56,9707,9708],{"class":174},"Log4jTest",[56,9710,1157],{"class":76},[56,9712,4612],{"class":174},[56,9714,4359],{"class":76},[56,9716,9717],{"class":58,"line":3668},[56,9718,9651],{"class":76},[56,9720,9721],{"class":58,"line":3685},[56,9722,4672],{"class":76},[16,9724,9725],{},"Let's see what kind of log we got — I think it's pretty self-explanatory 🙂",[47,9727,9729],{"className":49,"code":9728,"language":51,"meta":52,"style":52},"2011-06-27 14:42:19,507 [main]  INFO Log4jTest:12 – Initializing a new Student…\n\n2011-06-27 14:42:19,511 [main]  INFO Log4jTest:14 – new Student initialized: Tuncay Uzun\n",[20,9730,9731,9741,9745],{"__ignoreMap":52},[56,9732,9733,9735,9738],{"class":58,"line":59},[56,9734,8780],{"class":62},[56,9736,9737],{"class":66}," 14:42:19,507",[56,9739,9740],{"class":174}," [main]  INFO Log4jTest:12 – Initializing a new Student…\n",[56,9742,9743],{"class":58,"line":86},[56,9744,232],{"emptyLinePlaceholder":231},[56,9746,9747,9749,9752],{"class":58,"line":105},[56,9748,8780],{"class":62},[56,9750,9751],{"class":66}," 14:42:19,511",[56,9753,9754],{"class":174}," [main]  INFO Log4jTest:14 – new Student initialized: Tuncay Uzun\n",[16,9756,9757,9758,9760,9761,9763,9764,9767],{},"Now let's play with the xml file a bit and write the following expression under ",[1389,9759,9145],{}," to pull our log level from ",[1389,9762,8616],{}," down to the less verbose ",[1389,9765,9766],{},"warn",". (I wrote the ordering above 😉 )",[47,9769,9771],{"className":2994,"code":9770,"language":2995,"meta":52,"style":52},"\u003Clevel value=\"warn\" \u002F>\n",[20,9772,9773],{"__ignoreMap":52},[56,9774,9775,9777,9780,9782,9784,9786,9788,9790],{"class":58,"line":59},[56,9776,3467],{"class":76},[56,9778,9779],{"class":3293},"level",[56,9781,9111],{"class":3436},[56,9783,3440],{"class":76},[56,9785,312],{"class":76},[56,9787,9766],{"class":66},[56,9789,312],{"class":76},[56,9791,3896],{"class":76},[16,9793,9794,9795,9797,9798,9800,9801,9803],{},"If we run it again now, we see that no log is written 🙂 That is, with a single expression in the xml we made the log level of the entire project ",[1389,9796,9766],{}," and prevented our ",[1389,9799,8616],{}," logs from being written; only ",[1389,9802,9766],{}," and above messages, if any, will be seen 😉\nTake it easy.",[1188,9805,9806],{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}",{"title":52,"searchDepth":86,"depth":86,"links":9808},[],"Configuring Apache log4j: appender, layout, and log level settings.",{},"\u002Fen\u002Fblog\u002Flog4j-configuration",{"title":8791,"description":9809},"en\u002Fblog\u002Flog4j-configuration",[1758,8262],"\u002Fblog\u002Flog4j-configuration","wUxPHwU3lw5ZG7CO3IajGhdl-9tDmPyqdqMCzU415IE",{"id":9818,"title":9819,"body":9820,"date":10703,"description":10704,"extension":1203,"meta":10705,"navigation":231,"path":10706,"seo":10707,"stem":10708,"tags":10709,"translation":10710,"__hash__":10711},"pages_en\u002Fen\u002Fblog\u002Fxstream-java-to-xml-xml-to-java.md","XStream – Java to XML, XML to Java",{"type":8,"value":9821,"toc":10701},[9822,9831,9839,9988,10168,10586,10589,10689,10692,10698],[16,9823,9824],{},[1646,9825,9828],{"href":9826,"rel":9827},"https:\u002F\u002Fwww.sukrucakmak.com\u002Fwp-content\u002Fuploads\u002F2011\u002F06\u002Fxstream_logo.gif",[1650],[2168,9829],{"alt":52,"src":9830},"\u002Fimages\u002Fxstream-java-to-xml-xml-to-java-xstream_logo-300x98.gif",[16,9832,9833,9834,9838],{},"A very elegant library we can use to get the XML output of a Java object or to convert data given as XML back into a Java object. It lives at ",[1646,9835,9836],{"href":9836,"rel":9837},"http:\u002F\u002Fxstream.codehaus.org\u002F",[1650],".\nWhat needs to be done is quite simple: download the relevant jars and add them to our project's libraries.\nTo make the library's usage easy to understand, I explained it below through two objects named \"Ders\" (Course) and \"Ogretmen\" (Teacher); you can run the code in your own environment too.",[47,9840,9842],{"className":4139,"code":9841,"language":1758,"meta":52,"style":52},"package org.sukru.xstream.entity;\npublic class Ders {\n public Long id;\n public String ad;\n public Ogretmen ogretmen;\n public Ders(Long id, String ad, Ogretmen ogretmen) {\n this.id = id;\n this.ad = ad;\n this.ogretmen = ogretmen;\n }\n\u002F\u002Fgetters and setters\n}\n",[20,9843,9844,9864,9874,9885,9896,9907,9935,9949,9962,9975,9979,9984],{"__ignoreMap":52},[56,9845,9846,9848,9850,9852,9854,9856,9858,9860,9862],{"class":58,"line":59},[56,9847,4147],{"class":999},[56,9849,4150],{"class":3436},[56,9851,1157],{"class":76},[56,9853,4155],{"class":3436},[56,9855,1157],{"class":76},[56,9857,4160],{"class":3436},[56,9859,1157],{"class":76},[56,9861,4223],{"class":3436},[56,9863,2606],{"class":76},[56,9865,9866,9868,9870,9872],{"class":58,"line":86},[56,9867,4281],{"class":3436},[56,9869,4284],{"class":3436},[56,9871,4405],{"class":62},[56,9873,4290],{"class":76},[56,9875,9876,9878,9880,9883],{"class":58,"line":105},[56,9877,9348],{"class":3436},[56,9879,8352],{"class":3436},[56,9881,9882],{"class":174}," id",[56,9884,2606],{"class":76},[56,9886,9887,9889,9891,9894],{"class":58,"line":120},[56,9888,9348],{"class":3436},[56,9890,7961],{"class":3436},[56,9892,9893],{"class":174}," ad",[56,9895,2606],{"class":76},[56,9897,9898,9900,9902,9905],{"class":58,"line":248},[56,9899,9348],{"class":3436},[56,9901,4337],{"class":3436},[56,9903,9904],{"class":174}," ogretmen",[56,9906,2606],{"class":76},[56,9908,9909,9911,9913,9915,9917,9919,9921,9923,9925,9927,9929,9931,9933],{"class":58,"line":261},[56,9910,9348],{"class":3436},[56,9912,4405],{"class":2666},[56,9914,4306],{"class":76},[56,9916,8390],{"class":3436},[56,9918,9882],{"class":4315},[56,9920,4349],{"class":76},[56,9922,7961],{"class":3436},[56,9924,9893],{"class":4315},[56,9926,4349],{"class":76},[56,9928,4337],{"class":3436},[56,9930,9904],{"class":4315},[56,9932,4319],{"class":76},[56,9934,4290],{"class":76},[56,9936,9937,9940,9943,9945,9947],{"class":58,"line":274},[56,9938,9939],{"class":76}," this.",[56,9941,9942],{"class":174},"id ",[56,9944,3440],{"class":76},[56,9946,9882],{"class":174},[56,9948,2606],{"class":76},[56,9950,9951,9953,9956,9958,9960],{"class":58,"line":279},[56,9952,9939],{"class":76},[56,9954,9955],{"class":174},"ad ",[56,9957,3440],{"class":76},[56,9959,9893],{"class":174},[56,9961,2606],{"class":76},[56,9963,9964,9966,9969,9971,9973],{"class":58,"line":297},[56,9965,9939],{"class":76},[56,9967,9968],{"class":174},"ogretmen ",[56,9970,3440],{"class":76},[56,9972,9904],{"class":174},[56,9974,2606],{"class":76},[56,9976,9977],{"class":58,"line":318},[56,9978,9414],{"class":76},[56,9980,9981],{"class":58,"line":813},[56,9982,9983],{"class":130},"\u002F\u002Fgetters and setters\n",[56,9985,9986],{"class":58,"line":1913},[56,9987,4672],{"class":76},[47,9989,9991],{"className":4139,"code":9990,"language":1758,"meta":52,"style":52},"package org.sukru.xstream.entity;\npublic class Ogretmen {\n public String ad;\n public String soyad;\n public Ogretmen(String ad, String soyad) {\n this.ad = ad;\n this.soyad = soyad;\n }\n\u002F\u002Fgetters and setters\n@Override\n public String toString() {\n     return \"Ogretmen [ad=\" + ad + \", soyad=\" + soyad + \"]\";\n }\n}\n",[20,9992,9993,10013,10023,10033,10044,10066,10078,10091,10095,10099,10106,10119,10160,10164],{"__ignoreMap":52},[56,9994,9995,9997,9999,10001,10003,10005,10007,10009,10011],{"class":58,"line":59},[56,9996,4147],{"class":999},[56,9998,4150],{"class":3436},[56,10000,1157],{"class":76},[56,10002,4155],{"class":3436},[56,10004,1157],{"class":76},[56,10006,4160],{"class":3436},[56,10008,1157],{"class":76},[56,10010,4223],{"class":3436},[56,10012,2606],{"class":76},[56,10014,10015,10017,10019,10021],{"class":58,"line":86},[56,10016,4281],{"class":3436},[56,10018,4284],{"class":3436},[56,10020,4337],{"class":62},[56,10022,4290],{"class":76},[56,10024,10025,10027,10029,10031],{"class":58,"line":105},[56,10026,9348],{"class":3436},[56,10028,7961],{"class":3436},[56,10030,9893],{"class":174},[56,10032,2606],{"class":76},[56,10034,10035,10037,10039,10042],{"class":58,"line":120},[56,10036,9348],{"class":3436},[56,10038,7961],{"class":3436},[56,10040,10041],{"class":174}," soyad",[56,10043,2606],{"class":76},[56,10045,10046,10048,10050,10052,10054,10056,10058,10060,10062,10064],{"class":58,"line":248},[56,10047,9348],{"class":3436},[56,10049,4337],{"class":2666},[56,10051,4306],{"class":76},[56,10053,4309],{"class":3436},[56,10055,9893],{"class":4315},[56,10057,4349],{"class":76},[56,10059,7961],{"class":3436},[56,10061,10041],{"class":4315},[56,10063,4319],{"class":76},[56,10065,4290],{"class":76},[56,10067,10068,10070,10072,10074,10076],{"class":58,"line":261},[56,10069,9939],{"class":76},[56,10071,9955],{"class":174},[56,10073,3440],{"class":76},[56,10075,9893],{"class":174},[56,10077,2606],{"class":76},[56,10079,10080,10082,10085,10087,10089],{"class":58,"line":274},[56,10081,9939],{"class":76},[56,10083,10084],{"class":174},"soyad ",[56,10086,3440],{"class":76},[56,10088,10041],{"class":174},[56,10090,2606],{"class":76},[56,10092,10093],{"class":58,"line":279},[56,10094,9414],{"class":76},[56,10096,10097],{"class":58,"line":297},[56,10098,9983],{"class":130},[56,10100,10101,10103],{"class":58,"line":318},[56,10102,7930],{"class":76},[56,10104,10105],{"class":3436},"Override\n",[56,10107,10108,10110,10112,10115,10117],{"class":58,"line":813},[56,10109,9348],{"class":3436},[56,10111,7961],{"class":3436},[56,10113,10114],{"class":2666}," toString",[56,10116,6130],{"class":76},[56,10118,4290],{"class":76},[56,10120,10121,10124,10126,10129,10131,10133,10136,10138,10140,10143,10145,10147,10150,10152,10154,10156,10158],{"class":58,"line":1913},[56,10122,10123],{"class":2619},"     return",[56,10125,77],{"class":76},[56,10127,10128],{"class":66},"Ogretmen [ad=",[56,10130,312],{"class":76},[56,10132,5393],{"class":76},[56,10134,10135],{"class":174}," ad ",[56,10137,5398],{"class":76},[56,10139,77],{"class":76},[56,10141,10142],{"class":66},", soyad=",[56,10144,312],{"class":76},[56,10146,5393],{"class":76},[56,10148,10149],{"class":174}," soyad ",[56,10151,5398],{"class":76},[56,10153,77],{"class":76},[56,10155,2886],{"class":66},[56,10157,312],{"class":76},[56,10159,2606],{"class":76},[56,10161,10162],{"class":58,"line":3654},[56,10163,9414],{"class":76},[56,10165,10166],{"class":58,"line":3659},[56,10167,4672],{"class":76},[47,10169,10171],{"className":4139,"code":10170,"language":1758,"meta":52,"style":52},"package org.sukru.xstream.test;\nimport org.sukru.xstream.entity.Ders;\nimport org.sukru.xstream.entity.Ogretmen;\nimport com.thoughtworks.xstream.XStream;\npublic class XStreamTest {\n public static void main(String[] args) {\n \u002F\u002F Let's create a new teacher.\n Ogretmen ogretmen = new Ogretmen(\"Yasin\", \"Kenar\");\n \u002F\u002F Let's create a new course and set its teacher.\n Ders ders = new Ders((Long) 1L, \"Software Engineering\", ogretmen);\n \u002F\u002F The XStream magic starts now.\n XStream xstream = new XStream();\n xstream.alias(\"Ders\", Ders.class); \u002F\u002F we gave the Ders class a name,\n \u002F\u002F otherwise it also includes the\n \u002F\u002F package names.\n String xml = xstream.toXML(ders); \u002F\u002F we tell it to convert the ders object to xml.\n \u002F\u002F Let's see what kind of XML we produced.\n System.out.println(xml);\n \u002F\u002F Now let's give the generated XML back and get an object.\n Ders xmldenDers = (Ders) xstream.fromXML(xml);\n System.out.println(\"\\n XML den Ders: \"+xmldenDers.getId()+\" – \"+xmldenDers.getAd()+\" – \"+xmldenDers.getOgretmen().toString());\n }\n}\n",[20,10172,10173,10193,10217,10241,10261,10272,10294,10299,10330,10335,10371,10376,10390,10419,10424,10429,10452,10457,10475,10480,10507,10578,10582],{"__ignoreMap":52},[56,10174,10175,10177,10179,10181,10183,10185,10187,10189,10191],{"class":58,"line":59},[56,10176,4147],{"class":999},[56,10178,4150],{"class":3436},[56,10180,1157],{"class":76},[56,10182,4155],{"class":3436},[56,10184,1157],{"class":76},[56,10186,4160],{"class":3436},[56,10188,1157],{"class":76},[56,10190,4165],{"class":3436},[56,10192,2606],{"class":76},[56,10194,10195,10197,10199,10201,10203,10205,10207,10209,10211,10213,10215],{"class":58,"line":86},[56,10196,4172],{"class":999},[56,10198,4150],{"class":3436},[56,10200,1157],{"class":76},[56,10202,4155],{"class":3436},[56,10204,1157],{"class":76},[56,10206,4160],{"class":3436},[56,10208,1157],{"class":76},[56,10210,4223],{"class":3436},[56,10212,1157],{"class":76},[56,10214,4025],{"class":3436},[56,10216,2606],{"class":76},[56,10218,10219,10221,10223,10225,10227,10229,10231,10233,10235,10237,10239],{"class":58,"line":105},[56,10220,4172],{"class":999},[56,10222,4150],{"class":3436},[56,10224,1157],{"class":76},[56,10226,4155],{"class":3436},[56,10228,1157],{"class":76},[56,10230,4160],{"class":3436},[56,10232,1157],{"class":76},[56,10234,4223],{"class":3436},[56,10236,1157],{"class":76},[56,10238,4252],{"class":3436},[56,10240,2606],{"class":76},[56,10242,10243,10245,10247,10249,10251,10253,10255,10257,10259],{"class":58,"line":120},[56,10244,4172],{"class":999},[56,10246,4261],{"class":3436},[56,10248,1157],{"class":76},[56,10250,4266],{"class":3436},[56,10252,1157],{"class":76},[56,10254,4160],{"class":3436},[56,10256,1157],{"class":76},[56,10258,4135],{"class":3436},[56,10260,2606],{"class":76},[56,10262,10263,10265,10267,10270],{"class":58,"line":248},[56,10264,4281],{"class":3436},[56,10266,4284],{"class":3436},[56,10268,10269],{"class":62}," XStreamTest",[56,10271,4290],{"class":76},[56,10273,10274,10276,10278,10280,10282,10284,10286,10288,10290,10292],{"class":58,"line":261},[56,10275,9348],{"class":3436},[56,10277,4298],{"class":3436},[56,10279,4301],{"class":3436},[56,10281,492],{"class":2666},[56,10283,4306],{"class":76},[56,10285,4309],{"class":3436},[56,10287,4312],{"class":76},[56,10289,4316],{"class":4315},[56,10291,4319],{"class":76},[56,10293,4290],{"class":76},[56,10295,10296],{"class":58,"line":274},[56,10297,10298],{"class":130}," \u002F\u002F Let's create a new teacher.\n",[56,10300,10301,10303,10306,10308,10310,10312,10314,10316,10318,10320,10322,10324,10326,10328],{"class":58,"line":279},[56,10302,4337],{"class":3436},[56,10304,10305],{"class":174}," ogretmen ",[56,10307,3440],{"class":76},[56,10309,4334],{"class":2619},[56,10311,4337],{"class":2666},[56,10313,4306],{"class":76},[56,10315,312],{"class":76},[56,10317,4083],{"class":66},[56,10319,312],{"class":76},[56,10321,4349],{"class":76},[56,10323,77],{"class":76},[56,10325,4101],{"class":66},[56,10327,312],{"class":76},[56,10329,4359],{"class":76},[56,10331,10332],{"class":58,"line":297},[56,10333,10334],{"class":130}," \u002F\u002F Let's create a new course and set its teacher.\n",[56,10336,10337,10339,10341,10343,10345,10347,10350,10352,10354,10357,10359,10361,10363,10365,10367,10369],{"class":58,"line":318},[56,10338,4405],{"class":3436},[56,10340,5492],{"class":174},[56,10342,3440],{"class":76},[56,10344,4334],{"class":2619},[56,10346,4405],{"class":2666},[56,10348,10349],{"class":76},"((",[56,10351,8390],{"class":174},[56,10353,4319],{"class":76},[56,10355,10356],{"class":999}," 1L",[56,10358,4349],{"class":76},[56,10360,77],{"class":76},[56,10362,4057],{"class":66},[56,10364,312],{"class":76},[56,10366,4349],{"class":76},[56,10368,9904],{"class":174},[56,10370,4359],{"class":76},[56,10372,10373],{"class":58,"line":813},[56,10374,10375],{"class":130}," \u002F\u002F The XStream magic starts now.\n",[56,10377,10378,10380,10382,10384,10386,10388],{"class":58,"line":1913},[56,10379,4582],{"class":3436},[56,10381,4575],{"class":174},[56,10383,3440],{"class":76},[56,10385,4334],{"class":2619},[56,10387,4582],{"class":2666},[56,10389,4585],{"class":76},[56,10391,10392,10394,10396,10398,10400,10402,10404,10406,10408,10410,10412,10414,10416],{"class":58,"line":3654},[56,10393,4627],{"class":174},[56,10395,1157],{"class":76},[56,10397,4595],{"class":2666},[56,10399,4306],{"class":76},[56,10401,312],{"class":76},[56,10403,4025],{"class":66},[56,10405,312],{"class":76},[56,10407,4349],{"class":76},[56,10409,4405],{"class":174},[56,10411,1157],{"class":76},[56,10413,4612],{"class":174},[56,10415,8603],{"class":76},[56,10417,10418],{"class":130}," \u002F\u002F we gave the Ders class a name,\n",[56,10420,10421],{"class":58,"line":3659},[56,10422,10423],{"class":130}," \u002F\u002F otherwise it also includes the\n",[56,10425,10426],{"class":58,"line":3668},[56,10427,10428],{"class":130}," \u002F\u002F package names.\n",[56,10430,10431,10433,10435,10437,10439,10441,10443,10445,10447,10449],{"class":58,"line":3685},[56,10432,7961],{"class":3436},[56,10434,4622],{"class":174},[56,10436,3440],{"class":76},[56,10438,4627],{"class":174},[56,10440,1157],{"class":76},[56,10442,4632],{"class":2666},[56,10444,4306],{"class":76},[56,10446,5517],{"class":174},[56,10448,8603],{"class":76},[56,10450,10451],{"class":130}," \u002F\u002F we tell it to convert the ders object to xml.\n",[56,10453,10454],{"class":58,"line":3702},[56,10455,10456],{"class":130}," \u002F\u002F Let's see what kind of XML we produced.\n",[56,10458,10459,10461,10463,10465,10467,10469,10471,10473],{"class":58,"line":3711},[56,10460,7229],{"class":174},[56,10462,1157],{"class":76},[56,10464,4649],{"class":174},[56,10466,1157],{"class":76},[56,10468,4654],{"class":2666},[56,10470,4306],{"class":76},[56,10472,2995],{"class":174},[56,10474,4359],{"class":76},[56,10476,10477],{"class":58,"line":3721},[56,10478,10479],{"class":130}," \u002F\u002F Now let's give the generated XML back and get an object.\n",[56,10481,10482,10484,10487,10489,10491,10493,10495,10497,10499,10501,10503,10505],{"class":58,"line":3740},[56,10483,4405],{"class":3436},[56,10485,10486],{"class":174}," xmldenDers ",[56,10488,3440],{"class":76},[56,10490,5360],{"class":76},[56,10492,4025],{"class":174},[56,10494,4319],{"class":76},[56,10496,4627],{"class":174},[56,10498,1157],{"class":76},[56,10500,5473],{"class":2666},[56,10502,4306],{"class":76},[56,10504,2995],{"class":174},[56,10506,4359],{"class":76},[56,10508,10509,10511,10513,10515,10517,10519,10521,10523,10525,10528,10530,10532,10535,10537,10539,10541,10543,10545,10547,10549,10551,10553,10555,10557,10559,10561,10563,10565,10567,10569,10571,10573,10576],{"class":58,"line":3749},[56,10510,7229],{"class":174},[56,10512,1157],{"class":76},[56,10514,4649],{"class":174},[56,10516,1157],{"class":76},[56,10518,4654],{"class":2666},[56,10520,4306],{"class":76},[56,10522,312],{"class":76},[56,10524,5591],{"class":174},[56,10526,10527],{"class":66}," XML den Ders: ",[56,10529,312],{"class":76},[56,10531,5398],{"class":76},[56,10533,10534],{"class":174},"xmldenDers",[56,10536,1157],{"class":76},[56,10538,5522],{"class":2666},[56,10540,8694],{"class":76},[56,10542,312],{"class":76},[56,10544,5534],{"class":66},[56,10546,312],{"class":76},[56,10548,5398],{"class":76},[56,10550,10534],{"class":174},[56,10552,1157],{"class":76},[56,10554,5549],{"class":2666},[56,10556,8694],{"class":76},[56,10558,312],{"class":76},[56,10560,5534],{"class":66},[56,10562,312],{"class":76},[56,10564,5398],{"class":76},[56,10566,10534],{"class":174},[56,10568,1157],{"class":76},[56,10570,5575],{"class":2666},[56,10572,5578],{"class":76},[56,10574,10575],{"class":2666},"toString",[56,10577,7325],{"class":76},[56,10579,10580],{"class":58,"line":4663},[56,10581,9414],{"class":76},[56,10583,10584],{"class":58,"line":4669},[56,10585,4672],{"class":76},[16,10587,10588],{},"And the XML output looks like the one below.",[47,10590,10591],{"className":2994,"code":4016,"language":2995,"meta":52,"style":52},[20,10592,10593,10601,10617,10633,10641,10657,10673,10681],{"__ignoreMap":52},[56,10594,10595,10597,10599],{"class":58,"line":59},[56,10596,3467],{"class":76},[56,10598,4025],{"class":3293},[56,10600,3297],{"class":76},[56,10602,10603,10605,10607,10609,10611,10613,10615],{"class":58,"line":86},[56,10604,4032],{"class":76},[56,10606,4035],{"class":3293},[56,10608,178],{"class":76},[56,10610,1000],{"class":174},[56,10612,3313],{"class":76},[56,10614,4035],{"class":3293},[56,10616,3297],{"class":76},[56,10618,10619,10621,10623,10625,10627,10629,10631],{"class":58,"line":105},[56,10620,4032],{"class":76},[56,10622,4052],{"class":3293},[56,10624,178],{"class":76},[56,10626,4057],{"class":174},[56,10628,3313],{"class":76},[56,10630,4052],{"class":3293},[56,10632,3297],{"class":76},[56,10634,10635,10637,10639],{"class":58,"line":120},[56,10636,4032],{"class":76},[56,10638,4070],{"class":3293},[56,10640,3297],{"class":76},[56,10642,10643,10645,10647,10649,10651,10653,10655],{"class":58,"line":248},[56,10644,3290],{"class":76},[56,10646,4052],{"class":3293},[56,10648,178],{"class":76},[56,10650,4083],{"class":174},[56,10652,3313],{"class":76},[56,10654,4052],{"class":3293},[56,10656,3297],{"class":76},[56,10658,10659,10661,10663,10665,10667,10669,10671],{"class":58,"line":261},[56,10660,3290],{"class":76},[56,10662,4096],{"class":3293},[56,10664,178],{"class":76},[56,10666,4101],{"class":174},[56,10668,3313],{"class":76},[56,10670,4096],{"class":3293},[56,10672,3297],{"class":76},[56,10674,10675,10677,10679],{"class":58,"line":274},[56,10676,4112],{"class":76},[56,10678,4070],{"class":3293},[56,10680,3297],{"class":76},[56,10682,10683,10685,10687],{"class":58,"line":279},[56,10684,3313],{"class":76},[56,10686,4025],{"class":3293},[56,10688,3297],{"class":76},[16,10690,10691],{},"When we print the object created from the XML to the console, we see it looks like this.",[47,10693,10696],{"className":10694,"code":10695,"language":1226,"meta":52},[1224],"XML den Ders: 1 – Software Engineering – Ogretmen [ad=Yasin, soyad=Kenar]\n",[20,10697,10695],{"__ignoreMap":52},[1188,10699,10700],{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}",{"title":52,"searchDepth":86,"depth":86,"links":10702},[],"2011-06-15","Converting Java objects to XML and XML back to objects with the XStream library.",{},"\u002Fen\u002Fblog\u002Fxstream-java-to-xml-xml-to-java",{"title":9819,"description":10704},"en\u002Fblog\u002Fxstream-java-to-xml-xml-to-java",[1758,2995],"\u002Fblog\u002Fxstream-java-to-xml-xml-to-java","kcbCCmvoSYJNeBNAKr_AhiocQyPG28_rSh_-mo78UI8",{"id":10713,"title":10714,"body":10715,"date":11074,"description":11075,"extension":1203,"meta":11076,"navigation":231,"path":11077,"seo":11078,"stem":11079,"tags":11080,"translation":11082,"__hash__":11083},"pages_en\u002Fen\u002Fblog\u002Fintroduction-to-concurrency.md","Concurrency",{"type":8,"value":10716,"toc":11072},[10717,10723,10731,10744,10939,11043,11069],[16,10718,10719,10720,10722],{},"In Java, \"",[1389,10721,10714],{},"\" is the concept used when you need to do multiple things at the same time.\nIt has two basic operations;",[1729,10724,10725,10728],{},[1124,10726,10727],{},"Processes",[1124,10729,10730],{},"Threads",[16,10732,10733,10734,10736,10737,10740,10741,10743],{},"What immediately comes to mind is \"",[1389,10735,10730],{},"\". Each \"thread\" is a \"process\" in its own right. There are 2 ways to start a new \"thread\"; the first is to implement the \"",[1389,10738,10739],{},"Runnable","\" interface, the second is to subclass the \"",[1389,10742,2286],{},"\" object. Both examples are below;",[47,10745,10747],{"className":4139,"code":10746,"language":1758,"meta":52,"style":52},"public class HelloRunnable implements Runnable {\n    @Override\n    public void run() {\n        System.out.println(\"Hello from a thread!\");\n    }\n    public static void main(String args[]) {\n        Thread t = new Thread(new HelloRunnable());\n        t.start();\n        System.out.println(\"ID: \"+ t.getId());\n        System.out.println(\"NAME: \"+ t.getName());\n    }\n}\n",[20,10748,10749,10766,10772,10785,10808,10812,10833,10856,10868,10899,10931,10935],{"__ignoreMap":52},[56,10750,10751,10753,10755,10758,10761,10764],{"class":58,"line":59},[56,10752,4281],{"class":3436},[56,10754,4284],{"class":3436},[56,10756,10757],{"class":62}," HelloRunnable",[56,10759,10760],{"class":3436}," implements",[56,10762,10763],{"class":62}," Runnable",[56,10765,4290],{"class":76},[56,10767,10768,10770],{"class":58,"line":86},[56,10769,5206],{"class":76},[56,10771,10105],{"class":3436},[56,10773,10774,10776,10778,10781,10783],{"class":58,"line":105},[56,10775,4295],{"class":3436},[56,10777,4301],{"class":3436},[56,10779,10780],{"class":2666}," run",[56,10782,6130],{"class":76},[56,10784,4290],{"class":76},[56,10786,10787,10789,10791,10793,10795,10797,10799,10801,10804,10806],{"class":58,"line":120},[56,10788,4644],{"class":174},[56,10790,1157],{"class":76},[56,10792,4649],{"class":174},[56,10794,1157],{"class":76},[56,10796,4654],{"class":2666},[56,10798,4306],{"class":76},[56,10800,312],{"class":76},[56,10802,10803],{"class":66},"Hello from a thread!",[56,10805,312],{"class":76},[56,10807,4359],{"class":76},[56,10809,10810],{"class":58,"line":248},[56,10811,4666],{"class":76},[56,10813,10814,10816,10818,10820,10822,10824,10826,10828,10831],{"class":58,"line":261},[56,10815,4295],{"class":3436},[56,10817,4298],{"class":3436},[56,10819,4301],{"class":3436},[56,10821,492],{"class":2666},[56,10823,4306],{"class":76},[56,10825,4309],{"class":3436},[56,10827,4316],{"class":4315},[56,10829,10830],{"class":76},"[])",[56,10832,4290],{"class":76},[56,10834,10835,10838,10841,10843,10845,10848,10850,10852,10854],{"class":58,"line":274},[56,10836,10837],{"class":3436},"        Thread",[56,10839,10840],{"class":174}," t ",[56,10842,3440],{"class":76},[56,10844,4334],{"class":2619},[56,10846,10847],{"class":2666}," Thread",[56,10849,4306],{"class":76},[56,10851,5338],{"class":2619},[56,10853,10757],{"class":2666},[56,10855,7325],{"class":76},[56,10857,10858,10861,10863,10866],{"class":58,"line":279},[56,10859,10860],{"class":174},"        t",[56,10862,1157],{"class":76},[56,10864,10865],{"class":2666},"start",[56,10867,4585],{"class":76},[56,10869,10870,10872,10874,10876,10878,10880,10882,10884,10887,10889,10891,10893,10895,10897],{"class":58,"line":297},[56,10871,4644],{"class":174},[56,10873,1157],{"class":76},[56,10875,4649],{"class":174},[56,10877,1157],{"class":76},[56,10879,4654],{"class":2666},[56,10881,4306],{"class":76},[56,10883,312],{"class":76},[56,10885,10886],{"class":66},"ID: ",[56,10888,312],{"class":76},[56,10890,5398],{"class":76},[56,10892,6386],{"class":174},[56,10894,1157],{"class":76},[56,10896,5522],{"class":2666},[56,10898,7325],{"class":76},[56,10900,10901,10903,10905,10907,10909,10911,10913,10915,10918,10920,10922,10924,10926,10929],{"class":58,"line":318},[56,10902,4644],{"class":174},[56,10904,1157],{"class":76},[56,10906,4649],{"class":174},[56,10908,1157],{"class":76},[56,10910,4654],{"class":2666},[56,10912,4306],{"class":76},[56,10914,312],{"class":76},[56,10916,10917],{"class":66},"NAME: ",[56,10919,312],{"class":76},[56,10921,5398],{"class":76},[56,10923,6386],{"class":174},[56,10925,1157],{"class":76},[56,10927,10928],{"class":2666},"getName",[56,10930,7325],{"class":76},[56,10932,10933],{"class":58,"line":813},[56,10934,4666],{"class":76},[56,10936,10937],{"class":58,"line":1913},[56,10938,4672],{"class":76},[47,10940,10942],{"className":4139,"code":10941,"language":1758,"meta":52,"style":52},"public class HelloThread extends Thread {\n    public void run() {\n        System.out.println(\"Hello from a thread!\");\n    }\n    public static void main(String[] args) {\n        (new HelloThread()).start();\n    }\n}\n",[20,10943,10944,10960,10972,10994,10998,11020,11035,11039],{"__ignoreMap":52},[56,10945,10946,10948,10950,10953,10956,10958],{"class":58,"line":59},[56,10947,4281],{"class":3436},[56,10949,4284],{"class":3436},[56,10951,10952],{"class":62}," HelloThread",[56,10954,10955],{"class":3436}," extends",[56,10957,10847],{"class":62},[56,10959,4290],{"class":76},[56,10961,10962,10964,10966,10968,10970],{"class":58,"line":86},[56,10963,4295],{"class":3436},[56,10965,4301],{"class":3436},[56,10967,10780],{"class":2666},[56,10969,6130],{"class":76},[56,10971,4290],{"class":76},[56,10973,10974,10976,10978,10980,10982,10984,10986,10988,10990,10992],{"class":58,"line":105},[56,10975,4644],{"class":174},[56,10977,1157],{"class":76},[56,10979,4649],{"class":174},[56,10981,1157],{"class":76},[56,10983,4654],{"class":2666},[56,10985,4306],{"class":76},[56,10987,312],{"class":76},[56,10989,10803],{"class":66},[56,10991,312],{"class":76},[56,10993,4359],{"class":76},[56,10995,10996],{"class":58,"line":120},[56,10997,4666],{"class":76},[56,10999,11000,11002,11004,11006,11008,11010,11012,11014,11016,11018],{"class":58,"line":248},[56,11001,4295],{"class":3436},[56,11003,4298],{"class":3436},[56,11005,4301],{"class":3436},[56,11007,492],{"class":2666},[56,11009,4306],{"class":76},[56,11011,4309],{"class":3436},[56,11013,4312],{"class":76},[56,11015,4316],{"class":4315},[56,11017,4319],{"class":76},[56,11019,4290],{"class":76},[56,11021,11022,11025,11027,11029,11031,11033],{"class":58,"line":261},[56,11023,11024],{"class":76},"        (",[56,11026,5338],{"class":2619},[56,11028,10952],{"class":2666},[56,11030,5525],{"class":76},[56,11032,10865],{"class":2666},[56,11034,4585],{"class":76},[56,11036,11037],{"class":58,"line":274},[56,11038,4666],{"class":76},[56,11040,11041],{"class":58,"line":279},[56,11042,4672],{"class":76},[16,11044,11045,11046,11049,11056,11060,11061,11068],{},"As seen in both examples, the thread starts running with the \"",[1389,11047,11048],{},"Thread.start()",[4129,11050,11051,11052,11055],{},"\" call. Once it starts, it triggers the \"",[1389,11053,11054],{},"run()","\" method.",[4129,11057,11058],{},[1389,11059,6654],{}," ",[4129,11062,11063,11064,1157],{},"Based on ",[1646,11065,11066],{"href":11066,"rel":11067},"http:\u002F\u002Fdownload.oracle.com\u002Fjavase\u002Ftutorial\u002Fessential\u002Fconcurrency\u002Findex.html",[1650],"*\n**\n**",[1188,11070,11071],{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":52,"searchDepth":86,"depth":86,"links":11073},[],"2011-06-13","An introduction to concurrent programming in Java: the thread concept and the basic approaches.",{},"\u002Fen\u002Fblog\u002Fintroduction-to-concurrency",{"title":10714,"description":11075},"en\u002Fblog\u002Fintroduction-to-concurrency",[11081,1758],"concurrency","\u002Fblog\u002Fintroduction-to-concurrency","2qAtPwcHAHu3xEB6UCE9_JOvgyh7LimNT9FcEYPUCKs",1792353224453]