• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cant use java to execute files

 
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,

I am facing a weird problem. Whenever I am trying to execute a java program I get NoclassdefFound error and on including class path on command line I get bulk of error messages.

foll is a normal code which compiles error free(It is really a simple one)



I get this output:


Please tell me whats wrong in this?

thanks
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most likely, you have compiled the .java files with a more recent version of "javac" than the version of "java" you are using to execute it. Please use copy and paste not screenshots.

Execute the following commands:
java -version
javac -version

Examine your system and user PATH for older versions of Java preceding newer versions. If you are using -cp . then you have probably made some sort of mistake setting a classpath. It is usually a mistake to set a system classpath at all, so if you set a system classpath yourself, remove it. If the classpath was set automatically, add .; to its beginning.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post text for textual information rather than screenshots.

Edit: whoops, missed the previous exhortation; sorry.
 
Suvojit Chakraborty
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Most likely, you have compiled the .java files with a more recent version of "javac" than the version of "java" you are using to execute it.



Oh yes....I found the version of java as 1.3 in my system and javac as 1.6. Strangely, I dont know how Java interpreter became 1.3. Till yesterday everything was Ok and I was compiling and running my programs without any error.

But now I have installed JRE1.6 but still the problem persist.
please help to fix it.

Please use copy and paste not screenshots.



Ok I will take care of this in future.

Thanks
 
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suvojit:

Did you change your path to make sure that the 1.6 version of java and javac are being called?

John.
 
Saloon Keeper
Posts: 10687
85
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The 'public' that should be in front of the word 'class' is missing.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carey Brown wrote:The 'public' that should be in front of the word 'class' is missing.


Classes don't need to be public to be executed.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ooo, I had no idea.
 
Suvojit Chakraborty
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John de Michele wrote:

Did you change your path to make sure that the 1.6 version of java and javac are being called?



Oh yes! Environment variables are pointing to right folders.
here is the status of the path n classpath

classpath:C:\Program Files\Java\jre6;C:\Program Files\Java\jdk1.6.0_20\bin

path:H:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Java\jdk1.6.0_20\bin;C:\Program Files\Java\jre6

and following is result of jave -version:


I dont know what happened. Everything was OK till Thursday.....
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Suvojit Chakraborty wrote:
path:H:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Java\jdk1.6.0_20\bin;C:\Program Files\Java\jre6



What is C:\Program Files\Oracle\jre\1.3.1\bin;? Jre as in Java JRE?
The System will pick up the first JDK/JRE it finds. Ideally you should have only one JAVA_HOME variable on your system which points to your Java installation directory.
 
Suvojit Chakraborty
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:

What is C:\Program Files\Oracle\jre\1.3.1\bin;? Jre as in Java JRE?



I dont know what is this. I installed Oracle recently. Maybe it got installed along with oracle.
I will try to swap it with JDK's path. Let me see if this works......[fingers crossed]
 
Suvojit Chakraborty
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:

Suvojit Chakraborty wrote:
path:H:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Java\jdk1.6.0_20\bin;C:\Program Files\Java\jre6



What is C:\Program Files\Oracle\jre\1.3.1\bin;? Jre as in Java JRE?
The System will pick up the first JDK/JRE it finds. Ideally you should have only one JAVA_HOME variable on your system which points to your Java installation directory.





phew!!! at last its working.....I have put jdks path before oracles path.
Thank you mate.....u saved me from this mess, I was so frustrated...Thanks you so much....
now java n javac -version generates foll:

C:\Documents and Settings\suvojit123>javac -version
javac 1.6.0_20

C:\Documents and Settings\suvojit123>java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)



But I am still confused how and why did the classpath get swapped n whats is jre's connection with oracle....I am asking just out of curiosity. It will be great if you can anwser...

Thanks Again
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean the path, not classpath.

Like I mentioned before, the system will pick up the first JDK/JRE it finds.
I am guessing, someone installed some Oracle related stuff on your system. Maybe it came bundled with the 1.3 version?
 
Suvojit Chakraborty
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Maneesh Godbole wrote:You mean the path, not classpath.



Yes


Like I mentioned before, the system will pick up the first JDK/JRE it finds.
I am guessing, someone installed some Oracle related stuff on your system. Maybe it came bundled with the 1.3 version?



Yes I installed oracle 9i recently.
I understood that java must have came bundled with it but what has java to do in oracle? This is my question.
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A lot of Oracle is written in Java and it is notorious for adding an old version of Java at the beginning of your PATH. Something to do with its installer.

You should delete that classpath environment variable altogether, and not put your work into those folders.
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic