Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
| Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 4th, 2012, 02:49 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6.0_24-b07) Java Hot

Good Day ,
Please can anyone assist , the problem i am having is the following
when trying to compile my *.java File
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/M
ain
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.Main
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)
Could not find the main class: com.sun.tools.javac.Main. Program will exit.
Any assistance will be greatly appreciated
  #2 (permalink)  
Old January 4th, 2012, 08:46 AM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up main class not found exception

check your main class where you declare a main class,
check whether file name matches with class name ,
  #3 (permalink)  
Old January 4th, 2012, 08:53 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
Thanks for the reply , I am new to the JAVA language , so i am attempting to write code for the ("Hello World"!) App
I have checked the Hello.Java File name and this corresponds to the declaration
Code:
class Hello
I suspect that there may be something not correct with my Environment variables ??
  #4 (permalink)  
Old January 6th, 2012, 07:41 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compiling Java Program

Hi
I have since uninstalled the version of JRE and JDK i was using
and Installed Java (tm) SE Runtime Enviornment (Build 1.6.0_24-b07)
and JDK 1.6.0_24
to the following Directory C:\Program Files\Java.
In the JAVA Directory two sub folders exist the 1st being : jdk1.6.0_24 & jre6 ,
both have the correct \Bin Sub directories !
I also added the following value:C:\Program Files\Java\jdk1.6.0_24\bin to my Windows XP SP2 system environment variable called PATH


Also after checking the *java File where i declared the main Class
Code:
class Hello
and also checking the *name of the File to make sure that it is the same as the Class which it is, I still get the following error when trying to run the program
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
Caused by: java.lang.ClassNotFoundException: Hello
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)
Could not find the main class: Hello. Program will exit.
  #5 (permalink)  
Old January 10th, 2012, 10:34 PM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Your Classname and your Filename don't match

Can you post the contents of your class file, and also its filename?

The classname and filename don't match, it appears.
  #6 (permalink)  
Old January 11th, 2012, 01:49 AM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compiling Java Program

Code:
public class Hello
{
  public static void main (String[] args)
  {
  System.out.println("Hello World!");
  }

 }
Question how do i view the contents of the Hello.Class File?
The above code is from the Hello.java file
  #7 (permalink)  
Old January 11th, 2012, 12:36 PM
Registered User
Points: 16, Level: 1
Points: 16, Level: 1 Points: 16, Level: 1 Points: 16, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Run it like this:

Run it like so:

Code:
java Hello
I think you were running
Code:
java Hello.class //wrong way


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java SE Development Kit and Eclipse IDE for Java EE? Droider BOOK: Beginning Android Application Development 1 October 7th, 2011 08:42 AM
code needed "Professional Java 2 Enterprise Edition with BEA WLS" adnan206 J2EE 0 January 28th, 2011 06:17 AM
Need Java code for "print screen copy and paste" should act as an attachement on jsp. Dev programmer Java Basics 0 December 13th, 2010 06:26 AM
Add a CheckBox DataColumn to my DataGridView, Null format: "" or "True" but Error: F ismailc C# 2005 0 September 25th, 2009 04:56 AM
What "build in" funtionality can databound controls use (like GridV.) use with mySQL? allan_ravn ASP.NET 3.5 Professionals 0 April 14th, 2009 03:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.