viganothing
asked on
Classpath to?
Hello,
I'm tryin to load a simple Hello World on my screen using java.
I'm usin SuSe9.3.
I installed the latest Java and set the path to the new java dir.
Now when i'm tryin to :
vs187210:~/jre1.5.0_06 # java "test"
Exception in thread "main" java.lang.NoClassDefFoundE rror: test
I know this has something to do with the Classpath..but i'm not sure where to set the path to.
I tried into jre1.5.0_06/bin and lib too.Didn't work!
I installed Java on my home directory.
Also when i'm tryin to export PATH=/path/to/java:${PATH}
On the next login i get the old path ..which is older than the java i installed atm.
I'm tryin to load a simple Hello World on my screen using java.
I'm usin SuSe9.3.
I installed the latest Java and set the path to the new java dir.
Now when i'm tryin to :
vs187210:~/jre1.5.0_06 # java "test"
Exception in thread "main" java.lang.NoClassDefFoundE
I know this has something to do with the Classpath..but i'm not sure where to set the path to.
I tried into jre1.5.0_06/bin and lib too.Didn't work!
I installed Java on my home directory.
Also when i'm tryin to export PATH=/path/to/java:${PATH}
On the next login i get the old path ..which is older than the java i installed atm.
Hi, class name and file name should be same. Do you have a class called "test" ?
It would be helpful if you post the code
---
Harish
It would be helpful if you post the code
---
Harish
>>Also when i'm tryin to export PATH=/path/to/java:${PATH}
Did you put that in .bashrc (assuming Bash)?
Did you put that in .bashrc (assuming Bash)?
>> java "test"
try it without the quotes.
and it's case sensitive, so Test and test are not the same.
try it without the quotes.
and it's case sensitive, so Test and test are not the same.
and you should be using the jdk, not the jre.
>>try it without the quotes
shouldn't make any difference
>>and you should be using the jdk, not the jre.
Why?
shouldn't make any difference
>>and you should be using the jdk, not the jre.
Why?
isn't jre the runtime environment. We use the jdk to develop java applications.
ASKER
Actually i'm tryin to do a hello world so its not neccesary to have a class file.is it?
I tried also testin a class file but still the same error
I tried java test , java Test , java "test" , java "Test"
what else i should try?
I tried also testin a class file but still the same error
I tried java test , java Test , java "test" , java "Test"
what else i should try?
you need the class file no matter how small you application is.
did you try what CHEJ suggested, java -cp ./ test ?
did you try what CHEJ suggested, java -cp ./ test ?
>>Actually i'm tryin to do a hello world so its not neccesary to have a class file.is it?
Yes. Only class files can be run by a VM
Yes. Only class files can be run by a VM
ASKER
i tried the java -cp . filename.jar
I tried testin it with a classfile but still no diference.
I'm sorry but i'm a newbie maybe i'm just passin a pretty dump step but I need your assistance.
May be that my Classfiles are incorrect ( which i'm 90% sure they are correct ) but can you guys upload me a hello world classfile somewhere which i can test it.
Thanks
I tried testin it with a classfile but still no diference.
I'm sorry but i'm a newbie maybe i'm just passin a pretty dump step but I need your assistance.
May be that my Classfiles are incorrect ( which i'm 90% sure they are correct ) but can you guys upload me a hello world classfile somewhere which i can test it.
Thanks
Do you *have* a jar file? If so, try
java -jar filename.jar
java -jar filename.jar
what does your hello world code look like ?
Run the following thus
java -classpath . Props
http://www.sigma-software.freeserve.co.uk/misc/Props.class
java -classpath . Props
http://www.sigma-software.freeserve.co.uk/misc/Props.class
ASKER
CEHJ,
I guess this worked..it shows me some properties
[code]
java.runtime.name=Java(TM) 2 Runtime Environment, Stand...
sun.boot.library.path=/usr /lib/jvm/j ava-1.4.2- sun-1.4.2. 08/...
java.vm.version=1.4.2_08-b 03
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=:
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
user.country=US
sun.os.patch.level=unknown
java.vm.specification.name =Java Virtual Machine Specification
user.dir=/home/l2j
java.runtime.version=1.4.2 _08-b03
java.awt.graphicsenv=sun.a wt.X11Grap hicsEnviro nment
java.endorsed.dirs=/usr/li b/jvm/java -1.4.2-sun -1.4.2.08/ ...
os.arch=i386
java.io.tmpdir=/tmp
line.separator=
java.vm.specification.vend or=Sun Microsystems Inc.
os.name=Linux
sun.java2d.fontpath=
java.library.path=/usr/lib /jvm/java- 1.4.2-sun- 1.4.2.08/. ..
java.specification.name=Ja va Platform API Specification
java.class.version=48.0
java.util.prefs.Preference sFactory=j ava.util.p refs.FileS ystemPrefe rences...
os.version=2.4.20-021stab0 28.19.777- enterprise
user.home=/root
user.timezone=
java.awt.printerjob=sun.pr int.PSPrin terJob
file.encoding=ANSI_X3.4-19 68
java.specification.version =1.4
user.name=root
java.class.path=.
java.vm.specification.vers ion=1.0
sun.arch.data.model=32
java.home=/usr/lib/jvm/jav a-1.4.2-su n-1.4.2.08 /jre
java.specification.vendor= Sun Microsystems Inc.
user.language=en
java.vm.info=mixed mode
java.version=1.4.2_08
java.ext.dirs=/usr/lib/jvm /java-1.4. 2-sun-1.4. 2.08/...
sun.boot.class.path=/usr/l ib/jvm/jav a-1.4.2-su n-1.4.2.08 /...
java.vendor=Sun Microsystems Inc.
file.separator=/
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...
sun.cpu.endian=little
sun.io.unicode.encoding=Un icodeLittl e
sun.cpu.isalist=
[/code]
Don't mention the 1.4 version..cuz i haven't changed the path yet.
But it worked.
Now what do you think is the problem?
I guess this worked..it shows me some properties
[code]
java.runtime.name=Java(TM)
sun.boot.library.path=/usr
java.vm.version=1.4.2_08-b
java.vm.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
path.separator=:
java.vm.name=Java HotSpot(TM) Client VM
file.encoding.pkg=sun.io
user.country=US
sun.os.patch.level=unknown
java.vm.specification.name
user.dir=/home/l2j
java.runtime.version=1.4.2
java.awt.graphicsenv=sun.a
java.endorsed.dirs=/usr/li
os.arch=i386
java.io.tmpdir=/tmp
line.separator=
java.vm.specification.vend
os.name=Linux
sun.java2d.fontpath=
java.library.path=/usr/lib
java.specification.name=Ja
java.class.version=48.0
java.util.prefs.Preference
os.version=2.4.20-021stab0
user.home=/root
user.timezone=
java.awt.printerjob=sun.pr
file.encoding=ANSI_X3.4-19
java.specification.version
user.name=root
java.class.path=.
java.vm.specification.vers
sun.arch.data.model=32
java.home=/usr/lib/jvm/jav
java.specification.vendor=
user.language=en
java.vm.info=mixed mode
java.version=1.4.2_08
java.ext.dirs=/usr/lib/jvm
sun.boot.class.path=/usr/l
java.vendor=Sun Microsystems Inc.
file.separator=/
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport...
sun.cpu.endian=little
sun.io.unicode.encoding=Un
sun.cpu.isalist=
[/code]
Don't mention the 1.4 version..cuz i haven't changed the path yet.
But it worked.
Now what do you think is the problem?
Difficult to say if you only have binary code
If you post test.class somewhere, i may be able to tell you
posting your test.java file would be useful also.
>>posting your test.java file would be useful also.
Does that even exist?
Does that even exist?
I would hope so.
I mean come on, if you're learning java you should at least have the code form the start.
I mean come on, if you're learning java you should at least have the code form the start.
ASKER
dude..thats a 10mb proj..so dunno if that would be usefull for you?
ASKER
i'm not tryin to learn java..all i need is to run that project and i'm stuck at the java part!
>>dude..thats a 10mb proj.
That's an odd class name for something that size ;-) I'm on dial-up here - so maybe not ;-)
That's an odd class name for something that size ;-) I'm on dial-up here - so maybe not ;-)
Can you list the directory in which you think your project files reside?
Ok, so what are you doing with the hello world program then ?
ASKER
its a gameserver..
. l2jserver.jar
.. log
LoginServer_loop.sh log.cfg
RegisterGameServer.bat mysql-connector-java-3.1.1 0-bin.jar
RegisterGameServer.sh servername.xml
banned_ip.cfg sqljdbc.jar
c3p0-0.9.0.jar startLoginServer.bat
config startLoginServer.sh
console.cfg startSQLAccountManager.bat
javolution.jar startSQLAccountManager.sh
. l2jserver.jar
.. log
LoginServer_loop.sh log.cfg
RegisterGameServer.bat mysql-connector-java-3.1.1
RegisterGameServer.sh servername.xml
banned_ip.cfg sqljdbc.jar
c3p0-0.9.0.jar startLoginServer.bat
config startLoginServer.sh
console.cfg startSQLAccountManager.bat
javolution.jar startSQLAccountManager.sh
ASKER
what am i doing with the hello world is I just wanted to see that my Java is installed correctly.
ok, so did you manage to get the hello world running ?
It is ;-)
sh startLoginServer.sh
(?)
sh startLoginServer.sh
(?)
ASKER
actually i need to run this command to start the server
su -c "java -Xms512m -Xmx512m -cp javolution.jar:c3p0-0.9.0. jar:mysql- connector- java-3.1.1 0-bin.jar: l2jserver. jar net.sf.l2j.loginserver.Log inServer" UserHere
su -c "java -Xms512m -Xmx512m -cp javolution.jar:c3p0-0.9.0.
ASKER
Kelvin,
I successfully got the Props.class runnin
I successfully got the Props.class runnin
>>I successfully got the Props.class runnin
(Hence my last comment)
(Hence my last comment)
>>actually i need to run this command to start the server
You should avoid running it as root. Why do you need to?
You should avoid running it as root. Why do you need to?
cool : )
so what error do you get when u start the server now ?
so what error do you get when u start the server now ?
ASKER
i created a superuser..
I had some difficulties on creatin normal user with super permissions
So I had to create a Superuser.
Is that the issue?
I had some difficulties on creatin normal user with super permissions
So I had to create a Superuser.
Is that the issue?
ASKER
Exception in thread "main" java.lang.UnsupportedClass VersionErr or: net/sf/l2j/loginserver/Log inServer (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defi neClass0(N ative Method)
at java.lang.ClassLoader.defi neClass(Cl assLoader. java:539)
at java.security.SecureClassL oader.defi neClass(Se cureClassL oader.java :123)
at java.net.URLClassLoader.de fineClass( URLClassLo ader.java: 251)
at java.net.URLClassLoader.ac cess$100(U RLClassLoa der.java:5 5)
at java.net.URLClassLoader$1. run(URLCla ssLoader.j ava:194)
at java.security.AccessContro ller.doPri vileged(Na tive Method)
at java.net.URLClassLoader.fi ndClass(UR LClassLoad er.java:18 7)
at java.lang.ClassLoader.load Class(Clas sLoader.ja va:289)
at sun.misc.Launcher$AppClass Loader.loa dClass(Lau ncher.java :274)
at java.lang.ClassLoader.load Class(Clas sLoader.ja va:235)
at java.lang.ClassLoader.load ClassInter nal(ClassL oader.java :302)
at java.lang.ClassLoader.defi
at java.lang.ClassLoader.defi
at java.security.SecureClassL
at java.net.URLClassLoader.de
at java.net.URLClassLoader.ac
at java.net.URLClassLoader$1.
at java.security.AccessContro
at java.net.URLClassLoader.fi
at java.lang.ClassLoader.load
at sun.misc.Launcher$AppClass
at java.lang.ClassLoader.load
at java.lang.ClassLoader.load
ASKER
I read on the server forums something about this and they say I need to correct the classpath
It means you need to update your JRE. Can you post the output of
java -version
java -version
>>Is that the issue?
No, but it shouldn't run as root
No, but it shouldn't run as root
ASKER
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
ASKER
seems i'm runnin the latest version.
Hmm, just to be sure, can you post the the output of this?
su -c "java -version"
su -c "java -version"
ASKER
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
You got me!!
I did the export PATH=/path/to/java:${PATH}
which seems to be temporary.
I'm usin two version...cuz i still didn't put the PATH for java on bashrc or where i have to put that because i didn't find anything related to that.
I did the export PATH=/path/to/java:${PATH}
which seems to be temporary.
only a file called bash.bashrc where I can't find anything about the Java path .
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
You got me!!
I did the export PATH=/path/to/java:${PATH}
which seems to be temporary.
I'm usin two version...cuz i still didn't put the PATH for java on bashrc or where i have to put that because i didn't find anything related to that.
I did the export PATH=/path/to/java:${PATH}
which seems to be temporary.
only a file called bash.bashrc where I can't find anything about the Java path .
You need to run it with the other (later) version
export JAVA_HOME=<insert path to 1.5 install directory>
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$JAVA_HOME/bin:$PATH
ASKER
ok I did this
but yet if i type su -c"java -version" it shows me i have the older one.
but yet if i type su -c"java -version" it shows me i have the older one.
Well as i mentioned, you shouldn't be running as root, but if you must, you need to include the above lines in root's .bashrc
ASKER
OK i tried runnin with a normal user.
Still the same issue
Still the same issue
Can you post
su normaluser -c "java -version"
su normaluser -c "java -version"
ASKER
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
ASKER
can you tell me where exactly do i write the export path so it can be permanent.
that bash.bashrc?
Can i just write that on the first line?
that bash.bashrc?
Can i just write that on the first line?
There's your problem. You need to put those export commands in normaluser's .bashrc
>>Can i just write that on the first line?
I'd put it at the end
I'd put it at the end
ASKER
i'm sorry..i'm a newbie at this so can you tell me where do i find the normal users bashrc?
su normaluser
...
<your editor> .bashrc
...
<your editor> .bashrc
Domestic matters call. Back later
ASKER
OK i edited that.
Now i don't need to type after every login the export thingy
But on the su user -c "java -version" still keeps tellin me i'm usin the 1.4 version
Now i don't need to type after every login the export thingy
But on the su user -c "java -version" still keeps tellin me i'm usin the 1.4 version
And you've altered 'user's .bashrc
ASKER
yes..there was only a bash.bashrc file on etc and i altered that one.
I had to change into root account so i can edit the file
I had to change into root account so i can edit the file
>>on etc and i altered that one.
No. The right one's
/usr/home/user/.bashrc
No. The right one's
/usr/home/user/.bashrc
ASKER
I can't find a home folder under usr
su normaluser
<edit command> ~/.bashrc
<edit command> ~/.bashrc
ASKER
When i created my normal user ..i created from the / directory.
now when i type su user it gets me to the / dir
and there is no .bashrc file
now when i type su user it gets me to the / dir
and there is no .bashrc file
man useradd
> yes..there was only a bash.bashrc file on etc and i altered that one.
can you post the change you made
can you post the change you made
ASKER
sure,
I just added the followin lines on the end of the file
export JAVA_HOME=/path/to/java
export PATH=$JAVA_HOME/bin:$PATH
I tried creatin a normal user on several ways..i read some posts here on exchange but no effect.
I did the following
useradd -d /home/user username
it didn't show me the .bashrc on the home profile
also tried
useradd -d /home/user -s /../crsh username
but when i tried to log in it kept tellin me i type a wrong password.
I just added the followin lines on the end of the file
export JAVA_HOME=/path/to/java
export PATH=$JAVA_HOME/bin:$PATH
I tried creatin a normal user on several ways..i read some posts here on exchange but no effect.
I did the following
useradd -d /home/user username
it didn't show me the .bashrc on the home profile
also tried
useradd -d /home/user -s /../crsh username
but when i tried to log in it kept tellin me i type a wrong password.
if you've added it to bash.bashrc then you shouldn't need to cheange the users bashrc
what does the follwoing return:
/path/to/java/bin/java -version
/path/to/java/bin/java -version
ASKER
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
Whereever i type java -version i get this.
But when i type su -c "java -version" from anywhere i keep gettin this
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
btw, atm i'm having another problem!
I'm startin the server via sh LoginServer_loop.sh but when i go to logs i get an error something like this
Not enough space on Java blah blah
I'll post the exact error later ,my server is down atm so i can't get the error.
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
Whereever i type java -version i get this.
But when i type su -c "java -version" from anywhere i keep gettin this
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
btw, atm i'm having another problem!
I'm startin the server via sh LoginServer_loop.sh but when i go to logs i get an error something like this
Not enough space on Java blah blah
I'll post the exact error later ,my server is down atm so i can't get the error.
ASKER
this is the exact error
Could not reserve enough space for object heap
Could not create the Java virtual machine.
Could not reserve enough space for object heap
Could not create the Java virtual machine.
Try
su -m -c "java -version"
su -m -c "java -version"
ASKER
vs187210:~ # su -m -c "java -version"
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)
ASKER
anything?
If you su in that way, you won't have a problem with having the wrong JDK
ASKER
and what exactly means this
"Could not reserve enough space for object heap
Could not create the Java virtual machine."??
I know i'm gettin out of topic scope on every post but the whole topic is about how to bring that server alive.!!
"Could not reserve enough space for object heap
Could not create the Java virtual machine."??
I know i'm gettin out of topic scope on every post but the whole topic is about how to bring that server alive.!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
can u post LoginServer_loop.sh
ASKER
thanks a llot for your help i have some problems with my hosting so i'll close this thread and give you the points for all your time that you spent helping me (CEHJ)
:-)
java -classpath . test