LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-03-2009, 12:50 PM   #1
darkone66669
Member
 
Registered: Mar 2004
Distribution: Fedora 10
Posts: 85

Rep: Reputation: 15
Problem with java


I compiled a simple program with javac then when I tried to run it I got this error.

[Colin@localhost JavaSource]$ javac PCFixed.java
[Colin@localhost JavaSource]$ java PCFixed.class
Exception in thread "main" java.lang.NoClassDefFoundError: PCFixed/class
Caused by: java.lang.ClassNotFoundException: PCFixed.class
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
Could not find the main class: PCFixed.class. Program will exit.
[Colin@localhost JavaSource]$

I also tried another program I knew worked yesterday and it gave the same error. I was wondering if anybody knew what was wrong with this thing. When I use Netbeans everything goes ok but I don't like using it at the moment as these are all simple little programs that don't require the package statement and netbeans seems to think that everything needs to be in a package. I prefer freestyle anyway. Any help would be great.
 
Old 08-03-2009, 02:21 PM   #2
darenw
Member
 
Registered: Mar 2009
Location: Very humid Central Florida
Distribution: ArchLinux
Posts: 30

Rep: Reputation: 1
Did you define a main() method in that class?

public static void main(String[] args)
{
}
 
Old 08-03-2009, 02:31 PM   #3
darkone66669
Member
 
Registered: Mar 2004
Distribution: Fedora 10
Posts: 85

Original Poster
Rep: Reputation: 15
Yes main was defined. And when I tried to run one that was compiled and ran yesterday without error. Today there was an error. For some reason java command does not want to function on any programs. If you run the command by itself you get the list of options but if you try to run it on any .class files it gives the exact same error every time like it can't even find the file.
 
Old 08-21-2009, 07:01 PM   #4
darenw
Member
 
Registered: Mar 2009
Location: Very humid Central Florida
Distribution: ArchLinux
Posts: 30

Rep: Reputation: 1
Thumbs up Aha!

I hope this works for you. I've had the same problem and suddenly stumbled on the solution.

To run the program, it's
java PCFixed
not
java PCFixed.class
 
Old 08-25-2009, 04:58 PM   #5
darkone66669
Member
 
Registered: Mar 2004
Distribution: Fedora 10
Posts: 85

Original Poster
Rep: Reputation: 15
That fixed it thank you. Funny how simple the solution is.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java problem efus Linux - Software 8 09-18-2008 08:04 AM
Java problem, or is it? hate29 Linux - Software 1 01-17-2007 03:38 AM
Java problem CragStar Programming 11 03-11-2004 10:02 AM
Java problem Oliver Linux - Software 0 10-01-2003 04:01 AM
java problem bm1 Linux - Software 4 06-01-2003 08:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration