• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bad Class File?

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

I have a Java class called Test.java and comprises of the following code:

Without wanting to go into too much detail, this Test.java class is supposed to make a simple connection with the statistical language R.

In order to initate a connection, a class file called Rconnection.class was written by a developer to enable this. This class is in the same directory as Test.java.

When I try to compile Test.java, however, I get the following message:


Does anyone here know what this means and how I can get round this?

Many thanks
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sam,

The message is telling you that the Rconnection class is in the org.rosuda.JRclient package.

First up if you want make reference to the class without the package name (i.e. make references in your code as Rconnection), then you need an import statement in your code. You may already have done this.

Secondly, how has the Rconnection class been supplied to you? Has the statistical package been supplied as a stand alone jar file? If so, then you need to add the fully qualified path name of the jar file (including the jar file itself) to your classpath.

If a jar file has not been supplied, then you must ensure that the Rconnection class is in a directory called JRclient and that directory is a subdirectory of a directory called rosuda and that directory is a subdirectory of a directory called org. Now this directory structure must exist within your file system of a path listed in your classpath.

I apologise for the rather verbose response (it's late here on a Sunday night in Australia). If there is something in my response that doesn't make sense, then let me know and I'll see if I can explain it better.

Regards,
JD
 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply, but I have another file REXP.class in the same directory as the others and causes no problem when the java compiler compiles the line:

REXP x = c.evaluate("R.version.string");

And have done all that you have said.

This is getting interesting....
 
John Dell'Oso
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sam,

Perhaps the REXP class is a packageless class. Do you have the source code for this statistical package. If so, check the code for the Rconnection and REXP classes and I would suspect that the Rconnection class would have a line at the beginning of the code like "package org.rosuda.JRclient" and the REXP class would have no package line.

As I said in my previous post, we really need to better understand how the statistical package has been distributed (e.g. in a jar file?).

Regards,
JD
 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry John, i did forget to say...

The .class files were downloaded as a zip file. Inside the zip file were the following files:

jcrypt.class
Rconnection.class
RFactor.class
RFileOutputStream.class
Rpacket.class
RSrvException.class
RBool.class
REXP.class
RFileInputStream.class
RList.class
RSession.class
Rtalk.class

That's it.
 
John Dell'Oso
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK then,

When you open the zip file to list its contents do any of the .class files have a entry under the path column? If so, then that means that the class file belongs to that package.

Even better, do you have any java docs for this software? If so, you can then check the packages that the classes belong to.

Try this ... rename the zip file with a jar extension and then add the fully qualified path name of the jar file (including the name of the jar file) to your classpath. Don't forget that you will also need to add the relevant import statement(s) to your code ... see my first post regarding this.

Regards,
JD
 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hI jOHN.

I've just relalised there is one more final file in the zip file (not sure how i missed it the first time):

Mainfest.mf

Under the path column I read:

org\rusuda\RJclient for the .class files

and

meta-inf\ for the .mf file

As for "add the fully qualified path name of the jar file (including the name of the jar file) to your classpath." ...sorry to sound stupid but how do I do this? Do i go into my control panel > system > environmental variables or some other way?

I tried renaming the zip file but it remains RJclient.jar.zip....

Sam
 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John. Thanks for ALL your help. I've cracked it!

Yay for me!

Sam
 
John Dell'Oso
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sam,

Rename your file to RJclient.jar.

Now note down the directory that the jar file is in.

To add the jar file to your classpath, from the Control Panel, go to System, click on the Advanced tab, then click on the Environment Variables button. Under the system variables section, find the classpath variable, click on edit, and cursor to the end of the current classpath value, add a semi-colon and then add in the fully qualified name of the RJclient.jar file. For example, if the jar files resides in c:\foo1\foo2\RJclient.jar, then add this complete path to the classpath. Of course your directory names will be different.

Regards,
JD
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic