• Post Reply Bookmark Topic Watch Topic
  • New Topic

Running my first Java program using JRockit  RSS feed

 
Kerin Kapoor
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm trying to run my first Java program using JRockit on Linux server but getting the below error -

Exception in thread "Main Thread" java.lang.NoClassDefFoundError: /ap01/app/util/HelloWorld
Caused by : Java.lang.ClassNotFoundException: .ap01.cap.hyperion.utils.HelloWorld
at Java.net.URLClassLoader%1.run (URLClassLoader.java:202)
at Java.net.URLClassLoader.findclass (URLClassLoader.java:190)
at Java.Lang.ClassLoader.LoadClass (ClassLoader.java:306)
at sun.misc.Launch$AppClassLoader. loadClass (Launcher.java:308)
at Java.Lang.ClassLoader.LoadClass (ClassLoader.java:247)
Could not find the main class: /ap01/app/util/ HelloWorld. Program will exit.

The below steps are being used to run the HelloWorld program
1. Goto to JRockit bin directory
2. ./javac /ap01/app/util/HelloWorld.java
3. ./java /ap01/app/util/HelloWorld

After third step I get the above error.

The classic Hello world program is given below -



The version of Java is as follows -
Java version "1.6.0_29"
Oracle JRockit (R)

The version of linux is 2.6.18-371.1.2.0.1.e15.

Any pointers will be appreciated and I feel that its a basic mistake..

Thanks in advance!
 
Ron McLeod
Bartender
Posts: 1602
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try: ./java -cp /ap01/app/util HelloWorld
 
Kerin Kapoor
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

Is there a space between /ap01/app/util and HelloWorld in your command??

Thanks again!
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java command expects a class name, not a path. Don't use slashes; use dots, and make sure your classpath is correctly set to point to the base directory of the package of your program.

Assuming that your class HelloWorld is in the package ap01.app.util, and the base directory is /some/dir (you should ofcourse substitute this with your real directory) it should be something like this:

java -cp /some/dir ap01.app.util.HelloWorld
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have added code tags, which you should always use, to your post, and doesn't it look better
When you say “first program”, I hope you mean first program using JRockit rather than first program at all.
 
Ron McLeod
Bartender
Posts: 1602
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kerin Kapoor wrote:
Is there a space between /ap01/app/util and HelloWorld in your command??


Yes, and this is assuming that you had not defined a package name.
 
Kerin Kapoor
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone for the reply..That explains it!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!