This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Java Runtime Error  RSS feed

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

After surfing the World Wide Web, i got very little. It seems this is the only play where i can get help

Here is the problem :

I have a java program :


And i am usign this to get a connection with the database from a servlet,

the directory structure is :
C:\My Projects\BoaIntegratedWorkflow>java MyOracleConnection

It compiles fine,

but when i try to execute it the unwanted thing happens,

Exception in thread "main" java.lang.NoClassDefFoundError: MyOracleConnection (wrong name: com/system33/model/MyOracleConnection)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)


this is no less than BLUE SCREEN OF DEATH for me.

It works fine and fetches data if i drop package declararion/defination at the begining..



PLEASE HELP ME...PLEASE HELP ME....PLEASE HELP ME...

This is my last hope, or i have to move to COBOL, ha ha
[ August 08, 2008: Message edited by: David O'Meara ]
 
Ranch Hand
Posts: 83
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set the CLASSPATH envirnoment variable for the directory where you are storing the .class file.

If your MyOracleConnection.class file is in C:\MyCode directory then use this command

SET CLASSPATH=%CLASSPATH%;C:\MyCode

Then execute the java command it should work.

You may need to do this every time you close and reopen the Command prompt window.

Other way to avoid doing it again and again would be to go to

Right Click on My Computer -> Properties -> Advanced -> Environment Variables
Here create a new variable CLASSPATH (remember all caps and no mistake in spelling )

Enter the value C:\MyCode here ....

Hope this would help...
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is packaged as com.system33.model then it should exist somewhere on the runtime classpath as the file com/system33/model/MyOracleConnection.class

Once it is on the runtime classpath, you would run it as java com.system33.model.MyOracleConnection

It appears that the class was compiled correctly, but neither its location on the file system nor the method of execution are correct
 
Sachin Joshi
Ranch Hand
Posts: 83
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another thing I just noticed....

Looks like you have a package structure com/system33/model/MyOracleConnection

in this case you need to run the file like this

java com.system33.model.MyOracleConnection
 
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you must go through these tutorials:

CommonProblems
Packages
 
You'll never get away with this you overconfident blob! The most you will ever get is this tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!