aspose file tools*
The moose likes Beginning Java and the fly likes compiled or not compiled Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compiled or not compiled" Watch "compiled or not compiled" New topic
Author

compiled or not compiled

Chris Davies
Ranch Hand

Joined: Feb 26, 2003
Posts: 110
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


One day all greenhorns will run free ...
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

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.


    [Jess in Action][AskingGoodQuestions]
    Chris Davies
    Ranch Hand

    Joined: Feb 26, 2003
    Posts: 110
    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
    Marshal

    Joined: Jul 08, 2003
    Posts: 24184
        
      34

    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

    Joined: Feb 26, 2003
    Posts: 110
    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
    Dirk Schreckmann
    Sheriff

    Joined: Dec 10, 2001
    Posts: 7023
    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 ]

    [How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
    Chris Davies
    Ranch Hand

    Joined: Feb 26, 2003
    Posts: 110
    do i have to instantiate the webtopjdbc class ?

    like

    String webtopjdbc = new webtopjdbc ()?

    and place beneath the other string declarations ?
    Dirk Schreckmann
    Sheriff

    Joined: Dec 10, 2001
    Posts: 7023
    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

    Joined: Feb 26, 2003
    Posts: 110
    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

    Joined: Dec 10, 2001
    Posts: 7023
    What do your import statements look like? Did you import java.sql.Connection?
    Chris Davies
    Ranch Hand

    Joined: Feb 26, 2003
    Posts: 110
    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.*;




    ??
    Paul Sturrock
    Bartender

    Joined: Apr 14, 2004
    Posts: 10336

    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 ]

    JavaRanch FAQ HowToAskQuestionsOnJavaRanch
    Chris Davies
    Ranch Hand

    Joined: Feb 26, 2003
    Posts: 110
    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

    Joined: Apr 14, 2004
    Posts: 10336

    I'm sure I just said something about Java being case sensetive...
    Dirk Schreckmann
    Sheriff

    Joined: Dec 10, 2001
    Posts: 7023
    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

    Joined: Feb 26, 2003
    Posts: 110
    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

    Joined: Dec 10, 2001
    Posts: 7023
    If you look at the documentation, you'll notice two getString methods. What arguments do they take?
    Chris Davies
    Ranch Hand

    Joined: Feb 26, 2003
    Posts: 110
    "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
    Barry Gaunt
    Ranch Hand

    Joined: Aug 03, 2002
    Posts: 7729
    could it remotely be anything to do with the quantity of arguments to that there getString method?


    Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
    Getting someone to think and try something out is much more useful than just telling them the answer.
    Dirk Schreckmann
    Sheriff

    Joined: Dec 10, 2001
    Posts: 7023
    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

    Joined: Feb 26, 2003
    Posts: 110
    its compiled



    thanks for the assistance.

    now i'll wait for the runtime errors ...
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: compiled or not compiled