Java-for-beginners - Executing the Program

E-mail Print PDF
Article Index
Java-for-beginners
first code
code 1 explanation
Executing the Program
Fetch Data from NCBI
NCBI fetch reference
All Pages

Executing the Program

Now we know that the program is working fine (trying to be confident, but this hardly happens. You will need to debug and improve you code). Thus, you have to place the file in the webapps folder of your tomcat engine (assuming that you are using Apache Tomcat 5.5 engine with Java SE 5 and MySQL 5.0 on the Windows XP OS). Next open any browser window (after starting the tomcat engine service).

Type the path of your input html file (this file will get the input from client and then send the data to the java program, which will get the output from the db). Thus, here we have http://localhost:8080/ProteomDb/ImportFromEMBLDb.jsp .Type this in the browser and input the parameters in the resulting client page. Press the button and you will get a list of protein interactors on the resulting window.

Debugging or handling errors

Again, it is easy to get involved with an error, especially in programming. Thus, this try/catch block helps a lot in such cases. There is no standard way of solving errors in your code. However, you can save a lot of time by:-

1) Knowing the flow of the program. Are you sure that your program is following the correct logic.

2) Are you sure that the parameters are correctly defined?

3) It is good to print statements at each logic sub-unit of the code so that we can actually track if the program is executing fine or not. In case there is any error, you will know at which point the error has occurred.

4) Check the stack trace that is printed by Java. Mostly, it will give you the name of the exception. Just Google on the term or look in the Java API documentation to find out what does the error mean. Does some background check to solve the problem on the internet and you should get the solution to the problem.

5) Check if the internet is connected and that all the support environment requirements are properly running. For e.g.) The internet may not be connected and it may give you a ConnectTimeOut exception. Just google on the term ‘ConnectTimeOut’ and you will get a list of possible answers. One of the most common reasons is that the internet is not working properly or the input settings for connecting to the internet is wrong or missing.

6) In case you see a statement in the stacktrace, it will also show you the line no. Where this error occurred. Check the syntax of the statement in the API documentation or in the books to correct the code.

7) You must read and understand the Java language properly to be able to write a good program. Reading the above resources once is not enough. Practice is the key, for new beginners as well as experts. Everybody faces problems in coding and the more you know the language, the better will be you resulting program.



You are here: Tutorials Languages Java