• 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
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

classpath problem

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I test my baby these days , everything is ok before I put all files into jar,now when I run "java -jar server.jar" system tell me "XXXX_stub.class not found",I solve this problem with adding server.jar to CLASSPATH,but I don't know if it's leagle.Restrictions on RMI is different now,here it is
"Restrictions on RMI
To avoid unnecessary complexity in the marking environment certain restrictions are placed on solutions that use RMI. Specifically:

You must not require the use of an HTTP server.
You must not require the installation of a security manager.
You must provide all classes pre-installed so that no dynamic class downloading occurs.
You must use RMI over JRMP (do not use IIOP)"
I don't know what's the meaning of "You must provide all classes pre-installed so that no dynamic class downloading occurs" , may I require the test officer set the CLASSPATH as what I need before he run the server?
Thxs
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jian,

Originally posted by jian zheng:
...everything is ok before I put all files into jar,now when I run "java -jar server.jar" system tell me "XXXX_stub.class not found",I solve this problem with adding server.jar to CLASSPATH


You should not need to use CLASSPATH to solve this problem. My guess is that the XXXX_stub.class is not being put into the jar file correctly. For the sake of an example, let's say that the XXXX.class is in the following package: suncertify.remote.
For the purpose of this example I would expect you would run something like the following command:
rmic -v1.2 -classpath \xxxxxx\classes -d \xxxxxx\classes suncertify.remote.XXXX
This command will generate the suncertify.remote.XXXX_stub.class file in the classes/suncertify/remote directory.
Then I would expect that you would run a jar command similar to the following:
jar cvfm /xxxxxx/server.jar /xxxxxx/Manifest.MF -C /xxxxxx/classes .
So, if you were to run the following jar command:
jar tvf /xxxxxx/server.jar
You would see among the output produced the following entries:
suncertify/remote/XXXX.class
suncertify/remote/XXXX_stub.class
In other words, the XXXX_stub.class file should be in the same package directory structure as the file it was generated from (in this example, suncertify/remote). If it's in the jar file in any other package directory structure then it's not going to be found when the jar file is executed.


I don't know what's the meaning of "You must provide all classes pre-installed so that no dynamic class downloading occurs" , may I require the test officer set the CLASSPATH as what I need before he run the server?


One of the purposes of having the jar file is so that it can be completely self-contained. If the jar file is created correctly then you shouldn't need a particular CLASSPATH setup. Because it's possible to create the jar file so that a CLASSPATH is not required, I think it would be a bad idea to make the test officer do anything with the CLASSPATH. I don't know whether this would result in automatic failure, but it shouldn't be necessary and I wouldn't want to take the chance. The CLASSPATH environment variable is undefined when I run my project jar file.
Hope this helps,
George
[ February 06, 2004: Message edited by: George Marinkovich ]
 
jian zheng
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi George,
Thank you .I think you are right.I'll try to run the program without setting CLASSPATH.But I'm sure that I've put the "XXXX_stub.class" in right package and it's already been in the jar,here is my package structure:
-------------
suncertify.db
-------------
Data.class
RemoteData.class
RemoteDataImpl.class
RemoteDataImpl_Stub.class
xxxException.class
...
-------------
suncertify.srv
-------------
Server.class
-------------
suncertify.ui
-------------
XXXXXXXXX.class
XXXXX.class
.....
I bind RemoteDataImpl.class in Server.class,server.jar includes suncertify.db and sunertify.srv,and the main class is Server.class,is it ok?
The result is "XXXX_Stub not found" if I've not set CLASSPATH before I start rmiregistry,but "java -jar runme.jar server" is ok without "XXX_Stub not found".I got confused because client use "XXX_Stub.class" when it runs in server mode too.
I'll try like what you said,maybe I lost something,and I'll change the package structure if needed.
Thank you!George
Best Regards!
Jian
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi jian,

Originally posted by jian zheng:
Hi George,
Thank you .I think you are right.I'll try to run the program without setting CLASSPATH.But I'm sure that I've put the "XXXX_stub.class" in right package and it's already been in the jar,here is my package structure:
-------------
suncertify.db
-------------
Data.class
RemoteData.class
RemoteDataImpl.class
RemoteDataImpl_Stub.class
xxxException.class
...
-------------
suncertify.srv
-------------
Server.class
-------------
suncertify.ui
-------------
XXXXXXXXX.class
XXXXX.class
.....
I bind RemoteDataImpl.class in Server.class,server.jar includes suncertify.db and sunertify.srv,and the main class is Server.class,is it ok?
The result is "XXXX_Stub not found" if I've not set CLASSPATH before I start rmiregistry,but "java -jar runme.jar server" is ok without "XXX_Stub not found".I got confused because client use "XXX_Stub.class" when it runs in server mode too.
I'll try like what you said,maybe I lost something,and I'll change the package structure if needed.
Thank you!George
Best Regards!
Jian


As you said:because client use "XXX_Stub.class" when it runs in server mode too.So you have to include the XXX_Stub.class in the client's jar file.That is,the XXX_Stub.class must be placed in both client's jar file and server jar file.
Hope this helps,
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi JunKao and Jian,
You might want to consider having only a single executable file called runme.jar. You might find that you have a section of your assignment instructions similar to the following:


When you submit your assignment, each part (client and server) must be executable using a command of this exact form:
java -jar <path_and_filename> [<mode>]
Your programs must not require use of command line arguments other than the single mode flag, which must be supported. Your programs must not require use of command line property specifications. All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.
The mode flag must be either "server", indicating the server program must run, "alone", indicating standalone mode, or left out entirely, in which case the network client and gui must run.
You must not require manual editing of any files by the examiners.
Packaging of Submissions
All elements of your submission must be packaged in a single JAR file. The JAR file must have the following layout and contents in its root:
The executable JAR containing the programs. This must be called runme.jar.


If so, the simplest thing to do I think is to have a single executable called runme.jar that can operate in three different modes as described above: standalone, server, and network client.
Hope this helps,
George
[ February 07, 2004: Message edited by: George Marinkovich ]
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe creating:
If windows - a batch file or ant script
If Unix/Linux - a make script.
using this methods will help you run your application better, you can just set up your class paths in the files once and not changes will be needed unless you change the Package or File name.
I recommend ANT if you're familiar with it for running and testing your application.
http://ant.apache.org
get version 1.5+, try to stay away from version 1.6 since it is a beta version.
good luck.
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by George Marinkovich:
the simplest thing to do I think is to have a single executable called runme.jar that can operate in three different modes as described above: standalone, server, and network client.
Hope this helps,
George
[ February 07, 2004: Message edited by: George Marinkovich ]


I completely agree with George. You have to find a way to make the runme.jar your single point of execution, and it must be system independent.
M
 
jian zheng
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Thank you for your replies.As what you suggest I put all files into runme.jar(just one jar,I'm sorry I put files in two jars before ,it's a mistake),but still I need to set CLASSPATH=XXX\runme.jar to start the server before start rmiregistry,it looks like rmiregistry don't know where is XXX_Stub if I don't set CLASSPATH beforehand.But client is fine without CLASSPATH setting running in network mode,although it use XXX_Stub too.I test client in another machine without CLASSPATH.I really don't know what's the difference between my program with yours.
And I found server can't be start without CLASSPATH even if the code is not in jar.
Thks George,JunKao,Dixon and Max
Best Reards
Jian
[ February 08, 2004: Message edited by: jian zheng ]
[ February 08, 2004: Message edited by: jian zheng ]
 
jian zheng
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'm so excited ,I've solved this problem and know why to do so .
Here is what I've done:
I start rmiregistry in my code replace of starting it in command-line.
I just add "LocateRegistry.createRegistry(1099);" before binding the remote object.This way,of course rmiregistry will know where to get XXX_Stub now without CLASSPATH.
And what the test officer will do is to run "java -jar runme.jar server",he need not to start rmiregistry in command line even.
My mind is :
If I start rmiregistry in command line,rmiregistry do not know where to get XXX_Stub without CLASSPATH and codebase,but it'll find the XXX_stub when starting rmi is part of the whole application,it'll will find class in the jar.Is it right?
It's just my mind,and I want to hear some different voice
Best Regards!
Jian
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jian,
Congratulations on solving your problem.

Originally posted by jian zheng:
And what the test officer will do is to run "java -jar runme.jar server",he need not to start rmiregistry in command line even.


I think that's the best way to do it. If something can be done programmatically, then that's the way it should be done. It makes it much easier for the grader (there's one less thing that can go wrong). It simplifies the start application instructions in your user's guide as well.
Hope this helps,
George
 
jian zheng
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you George,I would still be in my wrong way about package instructure without your help.Thank you!
Best regards!
Jian
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic