Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: hibernate problem in linux

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default hibernate problem in linux

    Hi i am new to java and i have little knowledge of frameworks
    I used Hibernate in my project and its works fine in windows but in linux if i compile its giving error: Could not find or load main class

    check the below commands where i got stuck

    --- created java_home and path -------
    [root@saraswati ~]# echo $JAVA_HOME
    /usr/java/jdk1.7.0_04/bin/java
    [root@saraswati ~]# echo $PATH
    /usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.7.0_04/bin
    [root@saraswati ~]# cd /home/syslab/Downloads/src







    [root@saraswati src]# ls
    ------- these are the .java files-------
    Converter.java DataStorageHandler.java Hibernate.cfg.xml SensorReadings.hbm.xml UDPServer.java
    ConvertReadings.java FetchCoeff.java SensorMapping.java SensorReadings.java
    [root@saraswati src]# javac *.java


    ---- i am setting classpath inorder to compile .java files. lib folder contains all required libraries------

    [root@saraswati src]# export CLASSPATH=/home/syslab/Downloads/lib/*
    [root@saraswati src]# javac *.java
    [root@saraswati src]# java UDPServer
    Error: Could not find or load main class UDPServer
    ------- ths is the error i got -------




    [root@saraswati src]# java *
    Error: Could not find or load main class Converter.class
    --------------------------------------



    -------if i unset the classpath the code will run but it fails because of missing library files -------
    [root@saraswati src]# unset CLASSPATH
    [root@saraswati src]# java UDPServer
    Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/HibernateException
    at UDPServer.main(UDPServer.java:22)
    Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java: 355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.j ava:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:4 23)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:3 56)
    ... 1 more
    ------------- this is the error ------------------------------


    can anyone solve this problem i am totally stuck in this

    thanx in advance


  2. #2
    Member
    Join Date
    Apr 2012
    Location
    Superior, CO, USA
    Posts
    80
    Thanks
    0
    Thanked 14 Times in 14 Posts

    Default Re: hibernate problem in linux

    Quote Originally Posted by kirangk View Post
    [root@saraswati src]# export CLASSPATH=/home/syslab/Downloads/lib/*
    [root@saraswati src]# javac *.java
    [root@saraswati src]# java UDPServer
    Error: Could not find or load main class UDPServer
    First - why on earth are you running as root? This isn't Windows XP - do not run stuff as root unless absolutely needed!

    But the real issue is that the CLASSPATH variable eliminated the current directory from the CLASSPATH. So, either run:

    export CLASSPATH=/home/syslab/Downloads/lib/*:.

    (that's the path you have with a colon character and a . character)

    or run

    java -cp $CLASSPATH:. UDPServer

    (again : and . )
    Need Java help? Check out the HotJoe Java Help forums!

  3. The Following User Says Thank You to stdunbar For This Useful Post:

    kirangk (May 10th, 2012)

  4. #3
    Junior Member
    Join Date
    May 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: hibernate problem in linux

    WOW !!!! It worked Thank you very much for your time and help
    really feeling very happy

Similar Threads

  1. Replies: 0
    Last Post: July 27th, 2011, 10:31 AM
  2. Replies: 1
    Last Post: June 7th, 2011, 11:53 AM
  3. Problem with store procedures and Hibernate
    By zecute in forum JDBC & Databases
    Replies: 0
    Last Post: May 20th, 2011, 06:39 AM
  4. PRoblem Running Executable script in linux
    By ntu in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: May 2nd, 2011, 06:06 AM
  5. Hibernate Concepts
    By systech44 in forum Web Frameworks
    Replies: 2
    Last Post: March 12th, 2010, 07:32 AM