Results 1 to 15 of 31

Thread: Troubleshooting Guide For Some Basic Java Problems.

Threaded View

  1. #1
    Join Date
    Dec 2002
    Calgary, Canada

    Troubleshooting Guide For Some Basic Java Problems.

    Troubleshooting Guide For Some Basic Java Problems.

    Step One

    The first and fore most requirement is the installation of the required(or most current j2sdk, the newer versions of jdk are known as J2SE) from java.sun.com.
    if you have done that then you will have a new folder created in the C:\ drive.
    Typically it will be something along the following format
    C:\j2sdkxxxxx (I think jdk 5 is installed in C:\Program Files\ folders?)
    where xxxxx will be the version number for the current j2sdk you installed. At this point on my machine it looks like this

    Step Two

    Next step is setting up the path and class paths for your system so that windows knows what to do with commands like
    javac or java.
    Lets see what happens if we want to test our setup as it is right now.
    on your windows machine go to
    bottom left corner and click on
    in the text field type in
    if you are one of those who are still on win98/95 or win me then you will need to type in

    This will bring up a dos window. in the dos window at the prompt type in the following

    At this point we are expecting the following or a message like this

    'javac' is not recognized as an internal or external command
    operable program or batch file.

    This is due to the reason that windows machine does not know as yet that what to do with "javac" command which essentially
    is required to compile java src code.Close the does window,because windows will not apply new variable changes in this session,
    you will have to open up a new window once you are all set with variable settings.

    Step Three

    Lets go and set the environment variable.On machines with win2k or newer systems go to
    Start>Settings>Control Panel>
    Locate and click on the "System" icon.
    This will bring up "System Properties" window.
    by default "General" is selected, locate and click on "Advanced" tab.
    Locate and click on the button that has the following caption on it.

    Environment Variables

    This will bring up the a window with 2 sections in it, top one is for the user as whom you have logged in,and the lower
    section is for system.
    We will work in the user variables section.

    You will see 3 buttons right below the display window in the "user variables" section,

    New, Edit and Delete.

    we want to create home variable for java.Click on New button.
    It will bring up a small window with 2 text fields
    Variable name: _______________________
    in variable name text field type the following

    Variable value:______________________
    in the variable value field type the folder name + path where on C drive you have j2sdk installed.
    in my machine this value looks like this
    If you look in the window you will see the following record added which you have just added

    Variable Value

    JAVA_HOME C:\j2sdk1.4.1_05

    of course there may be others too.We are half way thru..:-)

    Step Four

    Now lets set the path to required java bin files to run several java commands.
    Look in the window for the user variables and try to locate a Variable name Path
    if you see one then we need to edit and add new values,if you don't see one then we need to create one.
    And then add values.
    First lets create one.

    You will see 3 buttons right below the display window in the "user variables" section,

    New, Edit and Delete.

    we want to create home variable for java.Click on New button.
    It will bring up a small window with 2 text fields
    Variable name: _______________________
    in variable name text field type the following

    Variable value:______________________
    in the variable value field type the folder name + path where on C drive you have j2sdk installed.
    in my machine this value looks like this
    If you look in the window you will see the following record added which you have just added.You will see that JAVA_HOME is
    resolved to its actual path on the disk, again on my machine it looks like below.

    Variable Value

    PATH C:\j2sdk1.4.1_05\bin;C:\j2sdk1.4.1_05\lib;

    Click "Ok" at the bottom of window, and then click on again.
    Now lets repeat Step Two here again.
    This time around(provided everything was done exactly as I mentioned above) when you type in javac at the command
    prompt you should get the following message

    C:\Documents and Settings\Khalid.Ali>javac
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are used
    -classpath <path> Specify where to find user class files
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -d <directory> Specify where to place generated class files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release
    -target <release> Generate class files for specific VM version
    -help Print a synopsis of standard options

    if we see the above message,we are all set for some serious java coding..:-).

    Compilation and Running of Java Code

    Open note pad, and copy and paste the following code in it
      public class HelloWorld{
     	public static void main(String[] args){
       		//declare and define a variable of type String
       		String helloWorld = "Hello Java World! Here I come.";
    		//Now print it out on screen
    There are couple of little precautions you will need to take.Make sure that file name is HelloWorld.java, class name must always
    match the file name.If everything is fine and dandy, nothing will happen and you will be brought back to the dos prompt.

    C:\development\java>javac HelloWorld.java


    In this case now is the time to run the newly written java application.if you want to make sure,just look in the directory where you have
    this file,now there is another file with the same name but different extension.

    java src files always have *.java extension and compiled classes have *.class extension.
    Anyways, let run this app, type in the following at the dos prompt.

    C:\development\java>java HelloWorld
    Hello Java World! Here I come.


    The java runtime engine will print the value of the variable then come to dos prompt for a new command.
    At this point typically a beginner may see the following error.

    C:\development\java>java HellowWorld
    Exception in thread "main" java.lang.NoClassDefFoundError: HellowWorld

    as you can see it makes total sense that its not finding the class name, because HelloWorld has a "w" in it,once the class name is
    corrected it will run.
    If you have class name that's different then the file name then you will get the following message.

    C:\development\java>javac HelloWorld.java
    HelloWorld.java:1: class HellowWorld is public, should be declared in a file named HellowWorld.java
    public class HellowWorld{
    1 error

    Obvious enough...I'll just go take a look at my class name and remove the w from so that its the same as the file name

    I hope this helps, I'd probably add more stuff as it comes to mind...
    Edit:Sep 06, 2005
    MySQL' centric jdk settings
    Following are the settings for MySQL to work on my windows 2000
    work station. Make sure you have same settings on your machines
    for MySQL to work.
    JDK installed at the following address
    Environment variable for java home set as follows
    Paths set to point to java home as follows
    Mysql driver is placed at the following location
    C:\Program Files\Java\j2re1.4.2\lib\mysql-connector-java-3.1.0-alpha-bin.jar
    I have attached a zip file that contains a DbTest.java class to test the
    Deploying a Servlet on Tomcat

    The tutorial above is mostly the works for any servlet on any server, only difference there will be that the root folders names could be different in different server environments.
    Sometimes people face problems in their JSP pages that their user created objects/classes throw an error that cannot resolve symbol. This error is almost always caused by the fact that there is a problem in the setup and the classes are not at right place for the jsp page to find them. Deploying a Servlet on Tomcat--> this tutorial will actually guide you through the process of setting up a correct context for any new webapplication as well as where required files should be at.
    Last edited by Khalid Ali; 03-27-2006 at 10:48 PM.


    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources
    Share on Google+

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.19906 seconds
  • Memory Usage 4,377KB
  • Queries Executed 14 (?)
More Information
Template Usage (31):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (4)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (31)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (31)postbit
  • (31)postbit_onlinestatus
  • (31)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./includes/functions_threadedmode.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • bbcode_parse_start
  • postbit_imicons
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates