• 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:

Having Trouble Compiling

 
Ranch Hand
Posts: 2274
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a folder c:\demo

In it I have my java file(simple for learning and testing):


The folder also contains a jt400.jar file.

My compile and error message is:

C:\>javac demo\Emailaddresses.java
demo\Emailaddresses.java:6: Class com.ibm.as400.access.AS400JDBCDataSource
not found in import.
import com.ibm.as400.access.AS400JDBCDataSource;
^
1 error
[ September 11, 2008: Message edited by: Steve Dyke ]
 
Steve Dyke
Ranch Hand
Posts: 2274
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone help with this?
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Put the jar file in classpath and then try compiling.
set CLASSPATH=%CLASSPATH%;name.jar;.

This is for windows environment.

Regds
Amit
 
Steve Dyke
Ranch Hand
Posts: 2274
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the jar file in the classpath but it still will not compile. What do I do next? Thanks for responding.

How ever I am getting a new error:

C:\>javac demo/Emailaddresses.java
demo\Emailaddresses.java:0: Class javax.sql.DataSource not found in class com.ib
m.as400.access.AS400JDBCDataSource.
package demo;
^
1 error
[ September 11, 2008: Message edited by: Steve Dyke ]
 
Marshal
Posts: 80281
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why have you started a new thread rather than continuing with your old thread?

If you have a folder called demo with a .java file inside starting with "package demo;" then you ought to have a folder called demo inside your folder called demo. Sure-fire recipe for confusion, I think.

Please get it to print out your classpath and tell us which folder you have the com.ibm.etc jar file. The hints from others that you have a classpath error are probably correct.
I shall have to introduce you to Campbell's Cheat technique: put all your classes into a folder, let's call it java_app, the unzip the .jar into that same folder.

And as for javac.sql.DataSource class: that appears to be a standard interface in the Java API which your AP400DataSource implements. Don't know why you can't find it.
 
Steve Dyke
Ranch Hand
Posts: 2274
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie:


And as for javac.sql.DataSource class: that appears to be a standard interface in the Java API which your AP400DataSource implements. Don't know why you can't find it.[/QB]



Right now this is the only trouble I am having.

My classpath

C:\WDSC\JAVA;.;C:\WDSC\sdk;C:\Demo\jt400.jar;C:\Demo\sqljdbc.jar;C:\Program Files\Ibm\Client Access\jt400\lib\uitools.jar;C:\Program Files\Ibm\Client Access\jt400\lib\jui400.jar;C:\Program Files\Ibm\Client Access\jt400\lib\data400.jar;C:\Program Files\Ibm\Client Access\jt400\lib\util400.jar;C:\Program Files\Ibm\Client Access\jt400\jre\lib\jhall.jar;C:\Program Files\IBM\Client Access\jt400\lib\x4j400.jar;C:\Program Files\IBM\Client Access\jt400\lib\jt400.jar;C:\Program Files\IBM\Client Access\jt400\lib\reportwriter.jar;C:\Program Files\IBM\Client Access\jt400\lib\composer.jar;C:\Program Files\IBM\Client Access\jt400\lib\outputwriters.jar;C:\Program Files\IBM\Client Access\jt400\lib\jasperreports.jar;C:\Program Files\IBM\Client Access\jt400\lib\JRtest1.jasper

Something I need cleared up. If I have an import statement in my java file, then I compile it, I realize that the compiler has to find the import file. Now after the class is created does it become self contained or will it still rely on being able to find the files for the import?
[ September 11, 2008: Message edited by: Steve Dyke ]
 
Campbell Ritchie
Marshal
Posts: 80281
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know. As you imply, that classpath is almost incomprehensible, but appears to have dozens of jt400 related jars in. But DataSource ought to be in one of the standard Java jars, in my case rt.jar, which is inside the jre/lib folder. Copy that jar somewhere and unzip it and see whether you can find DataSource. Beware: there are 3 files called DataSource; it is javax.sql.DataSource you want.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using a really old version of Java, older than 1.4? The class javax.sql.DataSource was added to the standard library in Java version 1.4.
 
Steve Dyke
Ranch Hand
Posts: 2274
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie:
Don't know. As you imply, that classpath is almost incomprehensible, but appears to have dozens of jt400 related jars in. But DataSource ought to be in one of the standard Java jars, in my case rt.jar, which is inside the jre/lib folder. Copy that jar somewhere and unzip it and see whether you can find DataSource. Beware: there are 3 files called DataSource; it is javax.sql.DataSource you want.



What can I do to make this not so clutered?

I have the rt.jar which does have the javax.sql package in it.

But you know I don't see a ref to the jre here. Do I need one?

[ September 12, 2008: Message edited by: Steve Dyke ]
[ September 12, 2008: Message edited by: Steve Dyke ]
 
Steve Dyke
Ranch Hand
Posts: 2274
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jesper Young:
Are you using a really old version of Java, older than 1.4? The class javax.sql.DataSource was added to the standard library in Java version 1.4.



I am using jre1.6.0_05
 
Campbell Ritchie
Marshal
Posts: 80281
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need to refer to the JRE; that was simply where you find the rt.jar file. Please check that DataSource is actually in it.
 
Steve Dyke
Ranch Hand
Posts: 2274
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie:
You don't need to refer to the JRE; that was simply where you find the rt.jar file. Please check that DataSource is actually in it.



I found the javax.sql package in my WDSC folder. So I added:
c:\WDSC\_jvm\jre\lib\server.jar to my classpath.

Now I get this error:

C:\>javac demo\Emailaddresses.java
error: Invalid class file format in C:\WDSC\_jvm\jre\lib\server.jar(javax/sql/Da
taSource.class). The major.minor version '48.0' is too recent for this tool to
understand.
demo\Emailaddresses.java:0: Class javax.sql.DataSource not found in class com.ib
m.as400.access.AS400JDBCDataSource.
package demo;
^
2 errors

Note: I also use the javac in the WDSC folder when compiling.
 
Campbell Ritchie
Marshal
Posts: 80281
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jesper is probably right.

Version 48.0 too recent? Start teasing your Java installation folder apart, and find the revision dates for the files in there. Try calling javac -version and java -version from the command line.

Version 48.0 is (if I remember correctly) Java 1.4. So you are somehow using a version of Java older than 1.4 ( ). Go through your PATH very carefully, looking for anywhere there might be an old version of Java, and move your entry for Java 1.6 before that. Look carefully for Oracle because that has a reputation for installing old versions of Java at the beginning of your PATH.

You don't need your Java installation folder in the CLASSPATH at all; you might as well remove it.
[ September 12, 2008: Message edited by: Campbell Ritchie ]
 
Steve Dyke
Ranch Hand
Posts: 2274
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Steve Dyke:


Something I need cleared up. If I have an import statement in my java file, then I compile it, I realize that the compiler has to find the import file. Now after the class is created does it become self contained or will it still rely on being able to find the files for the import?

[ September 11, 2008: Message edited by: Steve Dyke ]



No one has answered this for me yet.
 
Campbell Ritchie
Marshal
Posts: 80281
432
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, we don't appear to have noticed that question.

Have you tried it? Create two tiny classes in different packages so one invokes the other. Execute.
Delete the .class file and see what happens.
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic