aspose file tools*
The moose likes Beginning Java and the fly likes Having Trouble Compiling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Having Trouble Compiling" Watch "Having Trouble Compiling" New topic
Author

Having Trouble Compiling

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
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

Joined: Nov 16, 2004
Posts: 1466
    
    1
Can anyone help with this?
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 514
Hello,
Put the jar file in classpath and then try compiling.
set CLASSPATH=%CLASSPATH%;name.jar;.

This is for windows environment.

Regds
Amit


Regards,
Amit
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
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 ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
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

Joined: Nov 16, 2004
Posts: 1466
    
    1
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
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
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.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14268
    
  21

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1466
    
    1
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

Joined: Nov 16, 2004
Posts: 1466
    
    1
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
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
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

Joined: Nov 16, 2004
Posts: 1466
    
    1
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
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
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

Joined: Nov 16, 2004
Posts: 1466
    
    1
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
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Having Trouble Compiling