Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
help me in java
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
brainbarshan  
View profile  
 More options Jul 17 2009, 10:39 pm
Newsgroups: comp.lang.java.advocacy
From: brainbarshan <brainbars...@gmail.com>
Date: Fri, 17 Jul 2009 19:39:42 -0700 (PDT)
Local: Fri, Jul 17 2009 10:39 pm
Subject: help me in java
hi! i am new in java. i am just trying to learn it.
but i have got a problem. please anyone help me:
here is the code:

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

}

i save it as ap1.java in c: drive.
when i compile it with java :  javac ap1.java
it is compiled and a class file named ap1.class is created in c:
drive.
but when i am trying to run the class file by java ap1.class
it shows following errors:

 Exception in thread "main" java.lang.NoClassDefFoundError: ap1
Caused by: java.lang.ClassNotFoundException: ap1
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
320)
Could not find the main class: ap1.  Program will exit.

both java.exe and javac.exe are in c:\program files\java
\jdk1.6.0_14\bin

i set environmen variables as :
CLASSPATH --  C:\Program Files\Java\jdk1.6.0_14\bin
PATH            -   C:\Program Files\Java\jdk1.6.0_14\bin
in control panel--> system--> advanced-->Environment Variables

I cant get what is getting wrong....please help me out


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile  
 More options Jul 17 2009, 11:04 pm
Newsgroups: comp.lang.java.advocacy, comp.lang.java.help
From: Lew <no...@lewscanon.com>
Date: Fri, 17 Jul 2009 23:04:50 -0400
Local: Fri, Jul 17 2009 11:04 pm
Subject: Re: help me in java

brainbarshan wrote:
> hi! i [sic] am new in java [sic]. i am just trying to learn it.

The newsgroup comp.lang.java.help is perfect for this kind of question.
comp.lang.java.advocacy is for the expression of in favor of or against Java,
for or against parts of the language, for or against new features, or for or
against related products or projects.

> but when i am trying to run the class file by java ap1.class

The "java" command takes a class as an argument, not a file.  Class names are
similar to file names, but without the ".class" part, so you should type:

   java ap1

There are coding conventions for Java that one should begin class or other
interface names with an upper-case letter, and (most) variable and method
names with a lower-case letter.  Use single or compound words for names, such
as "class SomethingNifty"; each compound word part other than the first begins
with an upper-case letter for both classes and variables or methods.  So you
should get in the habit, using your example, of naming a class like:

   public class Ap1

and you would invoke it with

   java Ap1

Later you will learn about packages, which would give you a command like:

   java com.lewscanon.SomethingNifty

Read the material at <http://java.sun.com/>, especially the tutorials.

Please follow up at comp.lang.java.help .  Another good newsgroup is
comp.lang.java.programmer but it is somewhat more advanced.

Although the command to invoke a Java program is "java", the name of the
language is "Java".  The language itself is very picky about upper- and
lower-case spelling, so it's a good idea to get in the habit of rigor about
letter case generally.

--
Lew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
brainbarshan  
View profile  
 More options Jul 17 2009, 11:23 pm
Newsgroups: comp.lang.java.advocacy, comp.lang.java.help
From: brainbarshan <brainbars...@gmail.com>
Date: Fri, 17 Jul 2009 20:23:39 -0700 (PDT)
Local: Fri, Jul 17 2009 11:23 pm
Subject: Re: help me in java
On Jul 18, 8:04 am, Lew <no...@lewscanon.com> wrote:

> Lew wrote
> The "java" command takes a class as an argument, not a file.  Class names are
> similar to file names, but without the ".class" part, so you should type:

>    java ap1

but I have tried with java ap1.
it shows the same error.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rajjo  
View profile  
 More options Jul 19 2009, 1:45 am
Newsgroups: comp.lang.java.advocacy, comp.lang.java.help
From: Rajjo <rajith...@gmail.com>
Date: Sat, 18 Jul 2009 22:45:10 -0700 (PDT)
Local: Sun, Jul 19 2009 1:45 am
Subject: Re: help me in java
On Jul 18, 8:23 am, brainbarshan <brainbars...@gmail.com> wrote:

> On Jul 18, 8:04 am, Lew <no...@lewscanon.com> wrote:

> > Lew wrote
> > The "java" command takes a class as an argument, not a file.  Class names are
> > similar to file names, but without the ".class" part, so you should type:

> >    java ap1

> but I have tried with java ap1.
> it shows the same error.

Set this command in command prompt and try

set classpath=%classpath%;.;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lew  
View profile  
 More options Jul 19 2009, 11:57 am
Newsgroups: comp.lang.java.advocacy, comp.lang.java.help
From: Lew <no...@lewscanon.com>
Date: Sun, 19 Jul 2009 11:57:05 -0400
Local: Sun, Jul 19 2009 11:57 am
Subject: Re: help me in java

brainbarshan wrote:
>> but I have tried with java ap1.
>> it shows the same error.
Rajjo wrote:
> Set this command in command prompt and try

> set classpath=%classpath%;.;

The environment variable is "CLASSPATH", not "classpath".  The syntax you sow
is for Windows only; it will not work in other OSes.

It is far better not to set CLASSPATH at all.  If no CLASSPATH environment
variable is set, it defaults to "." (the current working directory), so this
step should not be necessary anyway.

The best way to set the class path is with the "-classpath" or "-cp" option to
the "java" command.  Again, this should not be necessary, since the default is
"." anyway, but the OP can try

   java -cp . Apl

--
Lew


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roedy Green  
View profile  
 More options Jul 20 2009, 11:51 am
Newsgroups: comp.lang.java.advocacy
From: Roedy Green <see_webs...@mindprod.com.invalid>
Date: Mon, 20 Jul 2009 08:51:55 -0700
Local: Mon, Jul 20 2009 11:51 am
Subject: Re: help me in java
On Fri, 17 Jul 2009 19:39:42 -0700 (PDT), brainbarshan
<brainbars...@gmail.com> wrote, quoted or indirectly quoted someone
who said :

> java ap1.class

just

java.exe Ap1

no .class.  It is illogical. javac.exe wants .java. but java.exe does
not want .class. Class names should start with a capital letter.

see http://mindprod.com/jgloss/helloworld.html

--
Roedy Green Canadian Mind Products
http://mindprod.com

"The industrial civilisation is based on the consumption of energy resources that are inherently limited in quantity, and that are about to become scarce. When they do, competition for what remains will trigger dramatic economic and geopolitical events; in the end, it may be impossible for even a single nation to sustain industrialism as we have know it in the twentieth century."
~ Richard Heinberg,  The Party s Over: Oil, War, and the Fate of Industrial Societies


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roedy Green  
View profile  
 More options Jul 20 2009, 11:53 am
Newsgroups: comp.lang.java.advocacy
From: Roedy Green <see_webs...@mindprod.com.invalid>
Date: Mon, 20 Jul 2009 08:53:05 -0700
Local: Mon, Jul 20 2009 11:53 am
Subject: Re: help me in java
On Fri, 17 Jul 2009 19:39:42 -0700 (PDT), brainbarshan
<brainbars...@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>hi! i am new in java. i am just trying to learn it.
>but i have got a problem. please anyone help me:
>here is the code:

You will have better luck with such questions in com.lang.java.help

see http://mindprod.com/jgloss/newsgroups.html
for what each group is best used for.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"The industrial civilisation is based on the consumption of energy resources that are inherently limited in quantity, and that are about to become scarce. When they do, competition for what remains will trigger dramatic economic and geopolitical events; in the end, it may be impossible for even a single nation to sustain industrialism as we have know it in the twentieth century."
~ Richard Heinberg,  The Party s Over: Oil, War, and the Fate of Industrial Societies


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roedy Green  
View profile  
 More options Sep 10 2009, 2:38 pm
Newsgroups: comp.lang.java.advocacy
From: Roedy Green <see_webs...@mindprod.com.invalid>
Date: Thu, 10 Sep 2009 11:38:47 -0700
Local: Thurs, Sep 10 2009 2:38 pm
Subject: Re: help me in java
On Fri, 17 Jul 2009 19:39:42 -0700 (PDT), brainbarshan
<brainbars...@gmail.com> wrote, quoted or indirectly quoted someone
who said :

> Exception in thread "main" java.lang.NoClassDefFoundError: ap1

see http://mindprod.com/jgloss/helloworld.html
http://mindprod.com/jgloss/runerrormessages.html#NOCLASSDEFFOUNDERROR
--
Roedy Green Canadian Mind Products
http://mindprod.com

"The coolest thing to do with your data will be thought of by someone else."
~ Rufus Pollock (born: 1978 age: 31) in Talk.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »