The author is always very good
1: JDK Development System Environment Variable Settings: Methods: WIN2000: Right-click My Computer - "Properties -" Advanced - "Environment Variable ClassPath = .; JDK Installer / libpath = JDK Installation Directory / bin : It must not be ignored ".". Win98: Modifying AutoCexe.bat is to modify the automatic batch file. Add: set classpath = .; jdk installation / libset Path = JDK installation directory / bin;% PATH%
2: (Prerequisite to set the system environment variable) Do not compile the bag, quite simple: Javac class name. Javajava class name
About the compilation problem of bag: If your class is packaged, you should compile the following method: Javac -d package, the parent class name. Javajava package name. Class name
3: Tomcat server configuration: 1): Set the system environment variable. 2): java_home = g: /jbuilder6/jdk1.3.1 g: /jbuilder6/jdk1.3.1 is a JDK installation directory 3): Tomcat_Home = Tomcat installation directory 4: Modify the Serlet without restart Tomcat modification% Tomcat_Home% / conf / server .xml is approximately as follows:
Then configure the WebShpere application server and Database Pilot: The first step: Tools -> Enterprise Setup -> Application Servers Set the installation path and the IBM's Java path, DB2 you look at your second step: Project -> Defaults Project Properties Servers Select WS4.0 and should be able to use WebShpere4.0 does not support EJB2.0, WebShpere5.0 support. Configuring Database Pilot Step 1: Add Category Library Tools -> Config Libraries Add Your Database Driver Table 2: Tools -> Enterprise Setup -> Database Drivers Add the class library you just added to the third step : After restarting JBilder, Tools -> DATABASE PILOT -> Option -> Drivers, add driver Step 4: New construction in Database Pilot Point, Driver: com.ibm.db2.jdbc.app.db2driver. URL: JDBC: DB2: DB_SDBC. (DB_SDBC is a DB2 database on the server). 7: Solve the Java Chinese Question: For Applet and AWT: 1 :) font f = new font (UIResource.getstring ("default_font", font. Plain, 12); UIManager.Put ("label.font", f); uimanager.put ("label.Foreground", color.black; uimanager.put; uimanager.put "Menu.font", f); uimanager.put ("MenuItem.font", f); uimanager.put ("list.font", f); UIManager.put ("Checkbox.Font", F); UIManager. PUT ("Radiobutton.font", F); UIManager.Put ("ComboBox.Font", F); UIManager.Put ("TextArea.font", F);
2 :) font f = new font ("Lishu", Font.Plain, 15); UIManager.Put ("Button.Font", Font); UIManager.Put ("ToggleButton.Font", Font); UIManager.put "Radiobutton.font", font; uimanager.put ("Checkbox.Font", font); UIManager.put ("colorchooser.font", font); UIManager.put ("ToggleButton.Font", font); UIManager. PUT ("ComboBox.Font", Font; UIManager.Put ("ComboBoxItem.font", Font); UIManager.put ("INTERNALFRAME.TITLEFONT", FONT); UIManager.put ("label.font", font); UIManager.put ("list.font", font); uimanager.put ("menubar.font", font); UIManager.put ("menu.font", font); UIManager.put ("MenuItem.Font", Font UIManager.Put ("RadiobuttonMenuItem.font", font); UIManager.Put ("CheckBoxMenuItem.font", font); UIManager.put ("Popupmenu.Font", font); UIManager.put ("optionpane.font" , font); UIManager.Put; UIManager.put ("ProgressBar.font", Font); UIManager.put ("scrollpane.font", font); UIManager.put ("Viewport" , font; uimanager.put ("tabbedpane.font", font); UIManager .put ("TableHeader.Font", Font; UIManager.put ("textfield.font", font); uimanager.put ("passwordfiled.font", font); UIManager.put ("TextArea.font", font) UIManager.put ("TextPane.Font", FONT); UIManager.Put ("EditorPane.Font", Font); UIManager.put ("Titledborder.Font", Font); UIManager.put ("Toolbar.Font", Font); UIManager.Put ("Tooltip.Font", Font; UIManager.put ("Tree.Font", Font);
3 :) For JSP and Servlet: Solution: First: Add: <% @ Page ContentType = "Text / HTML; Charset = GB2312"%> or HttpServletRequest Request, HttpservletRequest Request, HttpServletResponse Response Throws servletexception, ioException {response.setContentType ("text / html; charset = GB2312"); // This is an important above if you don't do it, use the following method before calling before the data is stored: public static string UnicoDetoChinese (String S) {Try {IF (s == null || s.equals (")) return" "; string news = null; newstring = new string (s.getbytes (" ISO8859_1 ")," GB2312 "); Return Newstring;} catch (unsupporteencodingexception e) {return s;}} public static string chinesetounicode (string s) {try {if (s == null || s.equals (")) Return"; string newstring = null; Newstring = new string (s.getbytes), "ISO8859_1"); return.com;} catch (unsupporteencodingexcection e) {return s;}}
3 :) Solve WebLogic / WebShpere Chinese Problem: The Chinese environment is required in the web.xml file.
R As:
} // If the file name is quoted IF (CDIS [0] .Charat (CDIS [0] .length () - 1) == '"') {Return CDIS [0] .substring (POS 6, CDIS [0 ] .length () - 1);} Return CDIS [0] .substring (POS 5, CDIS [0] .length ());}} 8: String Split: Public int getCount (String Str, String Sign) {// Find a number of Strs in a string, a number of occurrences of a specific substring S (Str == null) return 0; StringTokenizer S = New StringTokenizer (STR, SIGN); Return S.CountToKens ();} public string [ ] GetArray (String Str, String Sign) {// is marked by a specific substring S, the sub-string is intermediary. INT count = getcount (str, sign); int J = 0; string [] arr = new string [ Count]; for (int i = 0; i public String stringReplace (String sourceString, String toReplaceString, String replaceString) {String returnString = sourceString; int stringLength = 0; if (toReplaceString = null!) {stringLength = toReplaceString.length ();!} if (returnString = null && returnString. Length ()> stringLength) {int max = 0; String S4 = ""; for (int i = 0; i If (value) == "" // data returns "zero" Return "zero" 非 (isnan) // data illegal prompt, return to the air string {strerr = "data" Value "illegal!" Alert (strerr);} strCheck = value "; strCheck = strCheck.split (". "); strCheck = strarr [0]; if (strCheck.length> 12) / / Data is greater than or equal to 1 trillion, prompts to handle {strerr = "data" value "excessively, unable to handle!" Alert (strr); return ";} try {i = 0; strbig ="; intfen = Value * 100; // Convert to the value of the unit strfen = intfen.tostring (); strarr = strfen.split ("."); strfen = strarr [0]; intfen = strfen.length; // Get the length strarr = strfen.split ("); // Decompose each value into the While (INTFEN! = 0) // Decomposition and conversion {i = i 1; switch (i) // selection unit {casse 1: STRDW = "分"; Break; Case 2: strdw = "angle"; Break; Case 3: strdw = "yuan"; Break; case 4: strdw = "pick"; Break; Case 5: strdw = ""; Break; Case 6: strdw = "仟"; Break; Case 7: strdw = "10,000"; break; case 8: strdw = "Pick"; Break; Case 9: strdw = ""; Break; Case 10: strdw = ""; Break; casse 11: strdw = "hundreds"; Break; case 12: strdw = "pick"; Break; Case 13: strdw = ""; Break; case 14: strdw = "仟"; Break;} Switch (strarr [INTFEN-1]) // Select Number {CASE "1": Strnum = "壹"; Break; Case "2" : Strnum = ""; Break; Case "3": strnum = "叁"; Break; Case "4": strnum = ""; Break; Case "5": strnum = " "Break; Case" 6 ": Strnum =" Lu "; Break; Case" 7 ": strnum =" 柒 "; break; case" 8 ": strnum =" 捌 "; break; case" 9 ": strnum = ""; Breaf; case "0": strnum = "zero"; Break;} // Test a special case strnow = strbig.split (""); // Divided into zero-when IF ((i == 1) && (strr [intfen-1] == "0")) Strbig = " "; 为 时 情况 e i ((i == 2) && (Strarr [INTFEN-1] ==" 0 "))) {// Amount for zero (strbig! = "Whole") strbig = "zero" strbig;} // yuan is zero case ELSE IF ((i == 3) && (strarr [intfEN-1] == "0")) Strbig = "Yuan" Strbig; // Pick up - 中 且 且 零 零 零 零 零 零 零 零 零 零 零 (((i i)-) 补 ((i <7) && (i> 3) && (Strarr [intfen-1) ] == "0") && (STRNOW [0]! = "Zero") && (Strnow [0]! = "Yuan")) Strbig = "zero" strbig; // Pick up - 中 中 位And the previous one (element or more) is also zero, crossing ELSE IF ((i <7) && (I> 3) && (Strarr [INTFEN-1] == "0") && (STRNOW [0 ] == "zero")) {} // Pick up - 中 中 且 且 e i 过 跨 ELSE IF ((i <7) && (i> 3) && (i <7) && (i> 3) && (strarr [intfEN-1] == "0") && (STRNOW [0] == "yuan")) {} // When 万 万 万 万 ((i == 7) && Strarr [INTFEN-1] == "0")) Strbig = "10,000" strbig; // Pick up 10,000,000 in a zero and the previous one (more than 10,000) is not zero Else IF ((i <11) && (I> 7) && (strrr [INTFEN-1] == "0") && (Strnow [0]! = "zero") && (Strnow [0]! = "10,000 ")) Strbig =" zero " strbig; // Picking up 10,000,000 in a zero and the previous one (10,000) also crosss ELSE IF ((i <11) && I> 7) && (strrr [intfEN-1] == "0") && (strnow [0] == "10,000)) {} // 拾 万 - 中The bit is zero and the previous one is 10,000 and zero. Else IF ((i <11) && (i> 7) & & (strr [intfEN-1] == "0") && (Strnow [0] == "zero")) {} // million is zero and there is a position and more than 100,000 times, Else IF ((i <11) && (i> 8) && (strr [INTFEN-1]! = "0") && (STRNOW [0] == "10,000") && (Strnow [2] == "仟 ")) Strbig = Strnum StrDW " 10 零 " strbig.substring (1, strbig.length); // separately handle ELSE IF (i == 11) {/ / billion bits of zero When there is a position, go out to zero IF ((strnow [INTFEN-1] == "0") && (STRNOW [0] == "10,000") && (Strnow [2] == "")) Strbig = "100 million" "zero" strbig.substring (1, strbig.Length); // billion is zero and the full zero does not exist, remove the Else IF ((strarr [intfen-1] = = "0") && (STRNOW [0] == "10,000") && (Strnow [2]! = "仟")) Strbig = "100 million" strbig.substring (1, strbig.length); // billion When the position is not zero and the full zero, it will be lost to zero else if ((strNow [0] == "10,000") && (Strnow [2] == "仟") Strbig = Strnum strDW "Zero" strbig.substring (1, strbig.Length); // billion is not zero and unpredictable, removes Else IF ((strNow [0] == "10,000") && STRNOW [2]! = "")) Strbig = Strnum StrDW strbig.substring (1, strbig.Length); // Other normal conditions Else strbig = strnum strdw strbig;} // pick up billion - million billion The middle one is zero and the previous one (i <15) && (i> 11) && (strata) & quin (I <15) && (i> 11) && (strarr [intfen-1] == "0") && (STRNOW [0]! = "zero") && (STRN OW [0]! = "100 million")) Strbig = "zero" strbig; // picks up ELSE IF when it is zero, the previous one (hundred million) is also zero ((i <15) && (i> 11) && (strarr [intfEN-1] == "0") && (STRNOW [0] == "100 million")) {} // pick up 100 million yuan in zero, the previous one is 100 million ((I <15) && (I> 11) && (Strarr [INTFEN-1] == "0") && (Strnow [0] == "zero")) {} / / 100 million 位 且 且 ((i <15) && (i> 11) && (Strarr [INTFEN-1]! = "0" ) && (Strnow [0] == "zero") && (Strnow [1] == "100 million") && (Strnow [3]! = "仟") Strbig = Strnum StrDW strbig.substring (1, Strbig.Length); // billion is zero and there is 10 million and more than 10 billion times, in 100 million yuan to make up ELSE IF ((i <15) && (I> 11) && (Strarr [intfen-1 ]! = "0") && (STRNOW [0] == "zero") && (Strnow [1] == "100 million") && (Strnow [3] == "仟") Strbig = Strnum strDw " Zero " strbig.substring (2, strbig.Length); Else strbig = strnum strdw strbig; strfen = strfen.substring (0, intfen-1); intfen = strfen.length; strarr = strfen.split (" ");} Return strbig;} Catch (err) {return" "; // Returns the original value} 11: Remove all directories under the folder: / * * Delete all the files in a directory * / public Static void deLallFile (String Path) {file file = new file (path); if (! file.exists ()) return; if (! file.Indirectory ()) return; string [] templist = file.list (); File Temp = NULL; for (int i = 0; i 1 :) SimpleDateFormat Formatter = New SimpleDateFormat ("YYYY.MM.DD"); // Find to 2002.07.04 is illegal. String str = "2002.07.04"; paraSeposition POS = new paraSeposition (0); DATE DT = formatter.parse (STR, POS); if (dt! = Null) {// is a legal date} else {// illegal date } 2 :) Two dates are reduced to import java.util. *; Import java.text. *; Class a {public static void main (string [] args) {string s1 = "2003/08/15 17:15: 30 "; string s2 =" 2002/09/14 14:18:37 "; try {simpledateformat formatter = new SimpleDateFormat (" YYYY / MM / DD HH: MM: SS "); Parseposition POS = New PaSeposition (0); PARSEPSITION POS1 = New PaSeposition (0); DATE DT1 = Formatter.Parse (S1, POS); DATE DT2 = Formatter.Parse (S2, POS1); System.out.Println ("DT1 =" DT1); System.out .println ("DT2 =" DT2); long L = dt1.gettime () - DT2.Gettime (); System.out.Println ("Hello World! =" L);} catch (Exception E) {system .out.println ("exception" e.tostring ());}}} 3 :) Get 2 months later: Import java.util. *; import java.text.dateFormat; public class test2 {public static Void Main (String Args []) throws exception {string Date = "2001/11/30"; DateFormat DateFormat = DateFormat.getdateInstance (DateFormat.medium); Gregoriancalendar GRC = New Gregoriancalendar (); Grc.SetTime (New Date (Date); Grc.add (Gregoriancalendar.month, 2); System.out.println ("GRC =" DateFormat.Format (grc.gettime ()));}} 13: JSP / Servet Redirection Problem: Do not change the URL: 1: Servlet: Public void doget (httpservletRequest Request, httpservletResponse response) throws servletexception, ioException { GetServletContext (). getRequestDispatcher (TEST2URL) .forward (Request, Response); 2: JSP 1) Right-click "My Computer" selection attribute, select "Advanced" in the pop-up dialog box, then select the Environment Variable button, 2) Modify the TEMP, TEMP, TMPDIR options in "Administrator" and "System Variable", click Each option, then "Edit" (right), name TEMP, TEMP, TMPDIR The value is changed to C: / Winnt / Temp, of course, this is not necessary, just I suggest you do this. In fact, it is not difficult. If it is finished, the win2000 environment should have no problem. WebLogic 6.x section First, the JDBC Connection Pool configuration is used as an MYSQL small database. Before performing this configuration, let's put the database JDBC driver JAR file to the D: /bea/wlserver6.1/lib/jdbc (suggest this, there is no JDBC directory to build a), then edit D : /Bea/wlserver6.1/config/mydomain under the StartWeblogic.cmd file, add the JDBC driver file of the database in the ClassPath, such as red word: : runweblogicecho overset path =. / bin ;/ bin / OCI817_8; D: / Oracle / ORA81 / BIN;% path% set classpath =. / lib / cr_wls60f.jar; ./ lib / weblogic_sp.jar; ./ LIB / WebLogic.jar; ./ LiB / JDBC / mysql.jar In this way, WebLogic will only load the database JDBC driver used, and the configuration will be normal, otherwise the error will be reported. 1) Expand Services / JDBC / Connection Pools2 in the WebLogic console) Click Configure a New JDBC Connection Pool ... 3) Fill in each parameter, as follows: URL: JDBC: mysql: //127.0.0.1: 3306 / TestDriver classname: org.gjt.mm.mysql.driverproperties: user = root4) Don't forget I have added Apply to apply:) 5) The initial capacity, maximum capacity, capacity growth, and the like, can be configured according to the need to configure 6), and the above configuration work has not really true. Apply to WebLogic, so actions are one step, choose the Targets sign, select the Servers check, select MyServer in Available, then click "->", then click Apply Apply. This way that we do will really be actually effective. WebLogic will only know the JDBC Connection Pool II. Configuring Data Source 1) In the WebLogic Console, use the Services / JDBC / TX Data Sources2 in turn.) Click Configure A New JDBC TX. Data Source ... 3) Fill in each parameter, the result is as follows: JNDI Name: MySQLDataSorucePoolName: MySQLPoolrow Prefetch Size: 48Stream Chunk Size: 2564) Don't forget to apply Apply to apply :) -> ", then apply any apply. This way that we do will really be actually effective, and WebLogic will only know the DataSource we have configured. Configuration of JBuilder 7 I. Database driver loading Like WebLogic, before performing this configuration, first put the database JDBC JAR file to the D: / jbuilder7 / lib / jdbc directory (suggest this, there is no JDBC directory to build a) 1) Open JBUILDER 7, click Tools / Enterprise Setup ....... 2) Select the Database Drivers Sign 3 in the pop-up window) Point the Add button, pop up a new window (maybe you can have a slightly different) 4) Click the New ... button, pop up a new window, and change Name : The default value is mysql (as long as it makes sense, what is the name) 5) Click the Add ... button to find and add the JDBC driver that adds the database, of course, we go to D: / jbuilder7 / lib / jdbc Looking, choose mysql.jar, pay attention, don't expand mysql.jar, and select OK as the image. Tip: You can match the SHIFT and CTRL keys to select multiple .jar files. 6) The result is as follows, if there is a plurality of .jar files that need to be added, you can also click the Add ... button to continue adding. 7) OK exit .8) OK, then MySQL JDBC driver has been added. 9) OK again, JBuilder prompts to restart, the above configuration will take effect, determine and restart JBUILDER. Second, the configuration of EJB 2.0 and application servers, as an example of WebLogic 6.x To install Borland Enterprise Servler 5.02 before this configuration, IAS 4.5 is also a matter, both of them, of course, I have a new unused, installation process, because I installed it very easy! Basic is all the way back Car, I put my installation under D: / BorlandEnterpriseserver. 1) Open JBUILDER 7, click Tools / Enterprise Setup ....... 2) Select the CORBA sign, drop down the drop-down list box under Configuration, select Visibroker 3) Select Edit ..., pop-up Edit Confiuration window Click Path for orb Tools 4) Click Path for ORB Tools: Side ... Browse button, pop up the Select Directory window, select D: / BorlandEnterpriseServer5 / bin and OK. 5) Two times, OK, JBuilder asked you to restart, no way, do it, restart JBuilder. 6) After restart, go to Tools / Enterprise Setup ......., choose CORBA item, select Edit, select Library for Projects next to the pop-up window ... button 7) User in the new window in the pop-up You will find more options Borland Enterprise Server 5.0.2 Client, which is displayed in the picture, and then exits three times ok. 8) Select Project / Default Project Properties item 9) Select a Server sign in the dialog box, click ... Buttons, 10) In the new dialog box that pops up, select WebLogic Application Server 6.x , then Check if enable server, see the red box in the figure. 11) After checking Enable Server, other optional or detailed, click ... buttons, select Home Directory; select Working Directory; for your machine's WebLogic location. 12) Click on the Add button in the Class sign, add it to the D: /Bea/wlserver6.1/lib/cr_wls60f.jar file. As shown in the red line above. Use the MOVE UP button to move the D: /bea/wlserver6.1/lib/cr_wls60f.jar file, because generally added .jar files at the bottom side. This step is also more important, because WebLogic can be launched directly in the JBuilder environment, then it is necessary to test whether License is legal, that is, the cr_wls60f.jar file exists. 13) Select the Custom check, configure it as shown in the following red line, may have a different WebLogic directory location to have me, but it is the same. After configuring, click the OK button to exit Domain Name: MyDomain Server Name: MyServer Version: 6.1 Service Pack1 (D: /Bea/WLSer6.1) 14) Single Server for All Services in Project drop-down list box in the picture window Select WebLogic Application Server 6.x as shown, then OK exits. 15) When this JBuiler 7 is completed with WebLogic 6.x, then let's start! 15. Calculate the day period PUBLIC INT GETDAYS (Date SD, DATE ED) {Return (Ed.getTime () - SD.getTime ()) / (3600 * 24 * 1000)} 16. Date Add or decrease SimpleDateFormat SDF = New SimpleDateFormat ("YYYYMMDD"); string str = "20011230"; DATE DT = SDF.PARS (Str, New PaSeposition (0)); Calendar RightNow = Calendar.getInstance (); RightNow. SetTime (DT); RightNow.Add (Calendar.date, 2); // You have to decrease Date DT1 = rightnow.gettime (); string restr = sdf.format (dt1, ", new fieldPosition (0) ); System.out.println (restr); 17. Time display control first way: The second way: <% @ page import = "java.util. *, Java.text. *"%>
The third way: <% java.text.SIMPLEDATEFORMAT formatter = new java.text.SIMPLEDATEFORMAT ("YYYY Year MM Month Day"); java.util.date currentTime_1 = new java.util.date (); out.print (Formatter.Format (CurrentTime_1));%> Run results: July 31, 2001
The fourth way: <% java.text.SIMPLEDATEFORMAT formatter = new java.text.SIMPLEDATEFORMAT ("YYYY / MM / DD HH / MM / SS"); java.util.date currentTime_1 = new java.util.date () Out.print (currenttime_1));%> Run results: 2001/07/31 10/32/52 Third four ways actually the same he can generate a variable format. 18. Encryption & Decryption When the string STR is encrypted before inserting the database: java.net.urlencoder.Encode (String Str); decoding again when removed from the database: (You can do not encrypt, only decode, try it; No re-encryption) Java.Net.urdecoder.Decode (String STR);
19. Page refresh: There are three ways: 1. Set it in HTML:
2.jsp <% response.setHeader ("refresh", "1");%> No one second to refresh once