Re: Java server won't run after reboot

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Saturday 29 May 2004 05:44 pm, you wrote:
> That didn't work.  I still get the NoClassDefFoundError.  Any other
> ideas?

You're right !! it doesn't work. I just try this myself, and whenever I try to 
execute from outside the directory where the java files is located, I got the 
same error. I thought I've seen this and what I suggested was the solution, 
obviously not ! (Now it should be obvious that I am not a java developer 
myself, I just play with it sometime)

After some searching myself, I only have this solution:

If for example, my java program is in ~/project/testjava/helloworld.java, I 
can put in helloworld.java:

package project.testjava;
<rest of the src code>

then I need to go to ~, and compile it from there:
javac project/testjava/helloworld.java

and running it from there would work tpp:
java project/testjava/helloworld

The problems with the solution: First, I can't find a way so that I can use 
absolute path during compile and running (which is probably what you want in 
your case, since you're going to put the command in rc.local). So what I want 
is something so that I can say:

javac /home/<username>/project/testjava/helloworld.java
java /home/<username>/project/testjava/helloworld

when I tried, the solution does not work. I can't also figure out what to put 
in after the "package" keyword in the source code to make the absolute path 
work.

Secondly, the source code is dependent on what directory you want to compile 
and run the java program from. Unless I am missing something, that is just 
plain stupid !! Source code of a program should never be dependent on where 
the program is running from.

So that's it. I am kinda stuck right now too. I don't know if that would help 
you, but if you find the real solution, please let me know, cause right now 
it bugs the hell out of me too ! (BTW, I have a task of writing some java 
program in the near future, so this would be good to know).

I know this is going OT, but if anyone else on the list know a solution, 
please help.

RDB


> On Sat, 2004-05-29 at 11:59, Reuben D. Budiardja wrote:
> > On Saturday 29 May 2004 12:16 pm, Michael Sullivan wrote:
<snip>I wrote a java server that I want to start every time
> > > my server PC restarts.  I created a /usr/local/classes directory and
> > > copied Server.class and the support classes it uses there.  Id cd'd to
> > > /usr/local/classes and issued a java Server from there and it works
> > > fine, but if I issue a java /usr/local/classes/Server from anywhere
> > > outside the /usr/local/classes directory it tells me
> > >
> > > Exception in thread "main" java.lang.NoClassDefFoundError:
> > > /usr/local/classes/Server
<snip>
> > Try the following:
> > set the environment variable CLASSPATH to /usr/local/classes so that Java
> > knows where to find your classes. Asumming you're using bash:
> > $> export CLASSPATH=$CLASSPATH:/usr/local/classes
> >


-- 
Reuben D. Budiardja
Department of Physics and Astronomy
The University of Tennessee, Knoxville, TN
---------------------------------------------------------
"To be a nemesis, you have to actively try to destroy 
something, don't you? Really, I'm not out to destroy 
Microsoft. That will just be a completely unintentional 
side effect."
                 - Linus Torvalds -


-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux