• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

compiled or not compiled

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

when i run the javac command it returns to the prompt (giving no message as always - inferring its compiled), and yet its not there in the directory ?? i can't see it via command line or windows explorer interface ? ?

is this s runtime error ? i tried again with a simpler program and it has worked so can anyone tell me what it's doing ?

cheers

chris
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, if you told us:

  • Exactly what you typed
  • Your current working directory, and the location of your .java file
  • Precisely what you expected to find, and where


  • Then we might be able to help.
     
    Chris Davies
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Exactly what you typed

    i'm in a directory C:\beans, and i typed -

    javac -classpath "C:\beans\" webtopjdbc.java

    i have moved the two jar files basiswebtop.jar and basisjdbc.jar into the directory c:\beans




    do i have to instantiate the class ?

    do i have to use the import statements ?

    both jar files are in the directory so why wont it run ? or why does it pretend to compile ?

    cheers

    chris
     
    Ernest Friedman-Hill
    author and iconoclast
    Posts: 24207
    46
    Mac OS X Eclipse IDE Chrome
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Well, without your including the JAR files explicitly on the CLASSPATH (see HowToSetTheClasspath) this won't compile, because javac will not find any packages by the names you're importing, and for javac, that's a hard error. But you ought to see a message like




    and I can't explain why you're not; maybe someone else could guess?

    Anyway, you don't need those import statements, as you don't use those classes at compile time; but the jars should be on the CLASSPATH or you won't be able to run the program.
     
    Chris Davies
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    cheers

    i had the jars in the classpath which control panel/system/environment variables )is set at the following (i'm on win2k pro and j2se sdk 1.4.0_02 )-

    C:\Tomcat4.\lib\servlet.jar;C:\beans\basiswebtop.jar;C:\beans\basisjdbc.jar;

    when i use the following command

    javac -classpath "C:\beans\" webtopjdbc.java

    it returns to the prompt but does not compile.

    when i use the following command

    javac webtopjdbc.java

    i get the following



    i can't figure it out as curly brackets seem to be in place?

    cheers

    chris
     
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    i can't figure it out as curly brackets seem to be in place?

    When interpretting compiler error messages, the most important (and correct) ones are usually the first to appear. So, let's just look at the first one, and fix it first.



    What does the first error message say is expected? Do you have an idea where this missing item should go?
    [ May 27, 2004: Message edited by: Dirk Schreckmann ]
     
    Chris Davies
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    do i have to instantiate the webtopjdbc class ?

    like

    String webtopjdbc = new webtopjdbc ()?

    and place beneath the other string declarations ?
     
    Dirk Schreckmann
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I'll try to be more clear.

    What are the answers to the two questions I asked in my previous post above?

    The answers:

    A closing parenthesis is missing.

    The missing parenthesis should follow "catch (ClassNotFoundException exc".
     
    Chris Davies
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    thanks

    the following is now my problem. i have classpaths set in environment variables as well as setting it from the classpath - when i just try using the javac webtopjdbc i get the same error.

    i also tried setting the classpath at the command prompt using

    set classpath=.;%classpath%

    but still the same error as below



    this compilation is akiller
     
    Dirk Schreckmann
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    What do your import statements look like? Did you import java.sql.Connection?
     
    Chris Davies
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    i've now imported the following 3 packages and am now getting 7 errors as below (at least they're going down)

    import java.io.*;
    import java.sql.*;
    import java.util.*;




    ??
     
    Bartender
    Posts: 10336
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    One very important fact about Java, Chris Davies, is it is case sensetive.

    - Drivermanager is not a class in the JDK. However DriveManager is.

    - myStmtexecuteQuery is not a method of you class, however executeQuery(String query) is a valid method of the Statement object

    - printStackTRace is not a method of Exception. But printStackTrace is.

    Please Chris, I know any programming language can feel a little overwhelming when you are new to the discipline, but these errors are pretty clearly listed in your stack trace if you look at it carefully.

    [ May 27, 2004: Message edited by: Paul Sturrock ]
    [ May 27, 2004: Message edited by: Paul Sturrock ]
     
    Chris Davies
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    thanks. i always look for major difficulties and tend to be oblvious to the syntax.

    thanks also to the sherrif - i've put ijess in action on my amazon wish list - looks interesting

    i've only one left and its the following i'll investigate the synatx for accessing the system, unless you can see anything obvious

    webtopjdbc.java:32: cannot resolve symbol
    symbol : class Resultset
    location: class webtopjdbc
    Resultset myRs = myStmt.executeQuery("SELECT * from tour_all.employee");
     
    Paul Sturrock
    Bartender
    Posts: 10336
    Hibernate Eclipse IDE Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I'm sure I just said something about Java being case sensetive...
     
    Dirk Schreckmann
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    When figuring out what classes are available in the J2SE API, what those classes do, and even how to spell them correctly, I like to keep the J2SE API Documentation at hand for reference.

    Did you find the solution to your problem?

    Also, when putting together a program, large or small (but especially large), I always like to work in tiny little baby steps. I usually won't write another line of code if the previous line won't compile. This way, I've never more than about one or two compiler errors to deal with and think about, and they're most always in the same place - on the last line of code I just typed. So, I strongly suggest writing a little bit at a time, and compiling very often.
    [ May 27, 2004: Message edited by: Dirk Schreckmann ]
     
    Chris Davies
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    thanks, i figure out the capital 'S' in ResultSet (i wont forget that one)


    but i can't see this last one. i've checked the j2se api and there seems to nothing wrong with the capitalisation on the getString method, or using the previously assigned myRs variable or using the . in myRs.getString ?? ??


    webtopjdbc.java:36: cannot resolve symbol
    symbol : method getString (java.lang.String,java.lang.String)
    location: interface java.sql.ResultSet
    System.out.println(myRs.getString("name","job"));
     
    Dirk Schreckmann
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    If you look at the documentation, you'll notice two getString methods. What arguments do they take?
     
    Chris Davies
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    "If you look at the documentation, you'll notice two getString methods. What arguments do they take?"

    one takes getString(int columnIndex)

    the other getString(String columnName)


    but in the following code i can't see why it is a problem as both methods define the data types as String

    the getString method calls the two database fieldnames - "name" and "job",



    //Step 4: Process the Result Set

    while (myRs.next()) {

    System.out.println(myRs.getString("name","job"));



    though how does the variable myRs know which get String method its using ? is this what is causing the error ?

    thanks

    chris
     
    Ranch Hand
    Posts: 7729
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    could it remotely be anything to do with the quantity of arguments to that there getString method?
     
    Dirk Schreckmann
    Sheriff
    Posts: 7023
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    So, to be even more clear, getString(String) is not getString(String, String). What would a ResultSet.getString(String, String) method do, anyhow?
     
    Chris Davies
    Ranch Hand
    Posts: 110
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    its compiled



    thanks for the assistance.

    now i'll wait for the runtime errors ...
     
    It will give me the powers of the gods. Not bad for a tiny ad:
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic