For example, how to configure environment variables and How to Run Servlet? There are too many such problems. Now I want to write a beginner entry, so that it can be helpful for beginners! First, download the tool: I suggest using Editplus + JDK for beginners. I think it is easier to use Editplus + JDK for beginners, such as JB, Eclipse, and JCreator, but it does not know how to configure environment variables for beginners, Thus it is difficult to reach the point of knowing and knowing why. Then install JDK. I installed it under the c: JDK directory: Then there is the CLASSPATH problem: Just as the operating system uses PATH to search for executable programs, the Java Runtime Environment will traverse CLASSPATH to find classes. Even a simple program such as HelloWorld will traverse the JVM. CLASSPATH defines every path until the corresponding file is found. I believe that if your system is not 2 K or XP, you should set the Path as follows: My computer-> properties-> advanced-> Environment Variables Then append the following Path to the environment variable: C: JDKin;.; C: JDKlib You can also configure C: JDKin;.; C: JDKlibdt. jar; C: JDKlibools. jar. ★Remember: In the environment variables, remember not to be less. It indicates the current path. If there are fewer errors, you will say it! Dt. jar is a class library about the runtime environment, and tools. jar is a class library about some tools. If C: JDKin is not configured, "javac is not an internal or external command, or a program or batch file that can be run ." This error occurs. Then we should write the program: The first is (HelloWorld. java). Open Editplus and create a new Java file. Enter the following information to keep it case-insensitive: PublicclassHelloWorld { Publicstaticvoidmain (String [] args ){ System. out. println ("Hello, World! "); } } Then save the file (ctrl + s) to HelloWorld. java. Remember to distinguish the case sensitivity. HelloWorld. java is not helloworld. java or other Run the following command: Start-> Run-> cmd Switch the directory to the current directory in the console: JavacHelloWorld. java JavaHelloWorld You will see the output Hello, World on the console! (Not coming out? I have eaten my computer :)) Javac is a compilation command that compiles HelloWorld. java into HelloWorld. class. Java is the command to explain. JVM will explain and execute HelloWorld. class. At this time: 1. If predictioninthread "main" java. lang. NoClassDefFoundError: HelloWorld That is, you didn't add that. (dot) to the environment variable) 2. If predictioninthread "main" java. lang. NoSuchMethodError: main Or HelloWorld. java: 1: Publicclasshelloworldmustbedefinedinafilecalled "HelloWorld. java ". That is, you did not write this HelloWorld case-insensitive, or you did not save it as HelloWorld. java The name must be the same as that of publicclass. Let's talk about the problem of environment variables. Next, let's talk about how to compile and run the environment variables in Editplus, and choose Tools> parameter settings> Configure user Tools. 1. Add a tool (add an Application) Menu text: CompileJavaProgram Program: C: JDKinjavac.exe Parameter: File Name Initial Directory: file directory 2. Add a tool (add an Application) Menu text: RunJavaProgram Program: C: parameter: File Name (excluding the extension) Initial Directory: file directory You can add a tool group name, such as DebugJavaProgram. Then, in the drop-down menu of Tools, you will see the CompileJavaProgram and RunJavaProgram options. Then you can use ctrl + 1 to compile and ctrl + 2 to run the program. The following describes how to run Servlet: To run Servlet first, jsp (the first choice for SUN Enterprise Applications)/Servletcontainer is required. I recommend that you use tomcat (a very useful JSP running platform) for beginners ), download tomcat (a very useful JSP running platform) and decompress the compressed package: C: omcat (a good JSP running platform) Then configure the environment variable: Add three system variables: JAVA_HOME: C: JDK Tomcat (a very useful JSP running platform) _ HOME: C: omcat (a very useful JSP running platform) CLASSPATH: % JAVA_HOME % lib; % tomcat (a good JSP running platform) _ HOME % lib The environment variables of tomcat (a very useful JSP running platform) are configured. The following checks whether tomcat (a very useful JSP running platform) can run: In the console, go to the C: omcat (a very useful JSP running platform) in directory, run startup, and then return to a window, skip a bunch of things, and finally indicate that the Server has been running Enter http: // localhost: 8080 in the browser. If the welcome page appears, it means tomcat (a very useful JSP running platform) is okay. Write your first Servlet as above. Importjava. io .*; Importjavax. servlet .*; Importjavax. servlet. http .*; PublicclassHelloWorldextendsHttpServlet { PublicvoiddoGet (HttpServletRequestrequest, HttpServletResponseresponse) throwsServletException, IOException { Response. setContentType ("text/html "); PrintWriterout = response. getWriter (); Out. println ("Out. println ("ThisismyfirstServlet "); Out. println ("</title> Out. println ("Out. println ("</body> } } Then use javacHelloWorld. java to compile the file. If the file cannot be importjavax. servlet .* Then we should copy the servlet. jar file in C: omcat (a very useful JSP running platform) commonlib to C: JDKjrelibext and compile it again, so there is no problem! Then, in the C: omcat (a very useful JSP running platform) Directory of tomcat (a very useful JSP running platform), The web‑root file structure is as follows: ROOTindex.html ROOTwelcom. jsp (preferred for SUN Enterprise applications) ROOTWEB-INFlibMyServlet.jar (If your servlet. class is typed into a. jar file, put it under lib) ROOTWEB-INFclassesHelloWorld.class (put the HelloWorld. class file generated above in it) Then, enter http: // localhost: 8080/servlet/HelloWorld in the browser, and the Server will return the error Error404 -- NotFound. What's going on? Servlet must use C: omcat (a very useful JSP running platform. xml (standardization is getting closer and closer) file registration, open this web with EP. xml (standardization is getting closer and closer) files, Add <Servlet> <Servlet-name> HelloWorld </servlet-name> <Servlet-class> HelloWorld </servlet-class> </Servlet> <Servlet-mapping> <Servlet-name> HelloWorld </servlet-name> <Url-pattern>/servlet/helloworld </url-pattern> </Servlet-mapping> Such a structure <Servlet> <Servlet-name> HelloWorld </servlet-name> <Servlet-class> HelloWorld </servlet-class> </Servlet> Indicates the specified servlet class. The following structure <Servlet-mapping> <Servlet-name> HelloWorld </servlet-name> <Url-pattern>/servlet/HelloWorld </url-pattern> </Servlet-mapping> Specifies the URL mode to which HelloServlet maps. After modifying web. xml (standardization is getting closer and closer), restart the Server and then input http: // localhost: 8080/servlet/HelloWorld. Then, there is a big Hello, World! Waiting for you. Congratulations. Flat :) AI, the hands are tired. Write it here. I hope it will be helpful for beginners! ====================================== How to Create a database connection application? For example, connect to access (a favorite of small websites), and sqlsever. I heard that there are methods such as jdbcjdbc-odbc bridge. Currently, my machine only has jdk1.4. Do I need to install any other environment in jdbc mode? If you want a jdbc driver or other environment, where can I go? How can programs be written? -------------------------------- If the drive axle is used, you do not need to install anything else. In Control Panel --> Administrative Tools --> data source (ODBC) --> SystemDSN Add your database ing and select the corresponding database driver. Then you can |