The moose likes Java in General and the fly likes Problem running java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem running java program" Watch "Problem running java program" New topic

Problem running java program

murali dhary

Joined: Apr 13, 2010
Posts: 3

I have created a small project which has the below folder structure.

in source folder i have created structure like com/myorg/myapp/service, com/myorg/myapp/util, com/myorg/myapp/database folders.
in side util/database folders i have java classes that i use in my service class.
I have package statement in all my util classes as package com.myorg.myapp.util;
in side service class i have my service class which has package statment com.myorg.myapp.service;
in side database classes i have my service class which has package statment com.myorg.myapp.database;

After compiling java code from jdeveloper , i can run my service class which is producing desired results. I can run my service class from command promt also and it works fine. For this i have written a bat file which is as below.

java -classpath .;..;%MyApp%\classes;%MyApp%\lib\classes12.jar;%MyApp%\lib\classes12dms_g.jar;%MyApp%\lib\ojdbc14.jar;%MyApp%\lib\ojdbc14dms.jar com.myorg.myapp.service.MyService

Now i want to move this code to linux machine and run. i prepared shell script to run MyService class just the same as i have created dos bat file.
But i am not able to run. I am getting the following error.

Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: com.myorg.myapp.service.MyService
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib64/
at java.lang.Class.initializeClass() (/usr/lib64/
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib64/
at (/usr/lib64/
at _Jv_ThreadRun(java.lang.Thread) (/usr/lib64/
at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib64/
at __gcj_personality_v0 (/opt/oracle/NewCode/MyApp/java.version=1.4.2)
at __libc_start_main (/lib64/tls/
at _Jv_RegisterClasses (/opt/oracle/NewCode/MyApp/java.version=1.4.2)
Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in

any help to find what is causing this error....

Karthik Shiraly

Joined: Apr 04, 2009
Posts: 872

StringBuilder was introduced with Java 1.5. What version of java are you using? Stack trace seems to indicate 1.4.2.
murali dhary

Joined: Apr 13, 2010
Posts: 3
I am not using StringBuilder in my code.
but in the error trace its showing up. Jave version is 1.4.2

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15081

murali dhary wrote:I am not using StringBuilder in my code.

But maybe some code in one of the libraries that you are using, is using StringBuilder. Maybe one of those libraries requires Java 5 or newer, so it won't work on Java 1.4.

Which operating system and which version of Java are you using? Looking at the error messages, it looks like you're using a 64-bit version of Linux with GNU Java (gcj). Note that GNU Java is not a very good version of Java - it's an incomplete, not fully compatible and very slow implementation of Java 1.4.

I suggest you install a newer version of Sun Java, instead of using the default GNU version of Java that came with your operating system.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
murali dhary

Joined: Apr 13, 2010
Posts: 3
Thanks for the help. it worked with a different jdk. i was able to execute the same on a different box.
I agree. Here's the link:
subject: Problem running java program
It's not a secret anymore!