newbee in java programming

M

mil_ant

Hi

I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
public static void main( String[] args )
{
System.out.println( "Hello, World!" );
}
}

On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

What else must I do to simply get the Hello World message?

Regards
 
K

Knute Johnson

Hi

I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
public static void main( String[] args )
{
System.out.println( "Hello, World!" );
}
}

On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

What else must I do to simply get the Hello World message?

Regards

Did you compile it first? Do you have the compiler installed?

javac Hello.java

creates the Hello.class file. Then you type

java Hello
 
T

timjowers

I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
    public static void main( String[] args )
    {
        System.out.println( "Hello, World!" );
    }
}
 On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
What else must I do to simply get the Hello World message?

Did you compile it first?  Do you have the compiler installed?

javac Hello.java

creates the Hello.class file.  Then you type

java Hello


might need java -cp . Hello
-cp tells it where to look for the Hello.class file. "cp" stands for
CLASSPATH. Path of Class files. After you run javac to compile the
Hello.java from text into Hello.class p-code then open it up. Use
Notepad++ or something to open Hello.class. It is Java Machine code.
JVM code. "java" is the Java virtual machine program. It interprets
the .class stuff and calls down into the Operating System. On Linux
you can also easily see what calls are made into the OS. run, strace
java -cp . Hello
(On Solaris and some other Unixes this is called "truss"). It will
then print out all the calls made into the OS layer. Neato!
 
M

mil_ant

I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
    public static void main( String[] args )
    {
        System.out.println( "Hello, World!" );
    }
}
 On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
What else must I do to simply get the Hello World message?

Did you compile it first?  Do you have the compiler installed?

javac Hello.java

creates the Hello.class file.  Then you type

java Hello

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
             ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Hi

I cannot use the javac command. I dont´have it on my system. I do have
the full install of JDK on my machine<
 
K

Knute Johnson

timjowers said:
Hi
I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
public static void main( String[] args )
{
System.out.println( "Hello, World!" );
}
}
On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
What else must I do to simply get the Hello World message?
Regards
Did you compile it first? Do you have the compiler installed?

javac Hello.java

creates the Hello.class file. Then you type

java Hello


might need java -cp . Hello
-cp tells it where to look for the Hello.class file. "cp" stands for
CLASSPATH. Path of Class files. After you run javac to compile the
Hello.java from text into Hello.class p-code then open it up. Use
Notepad++ or something to open Hello.class. It is Java Machine code.
JVM code. "java" is the Java virtual machine program. It interprets
the .class stuff and calls down into the Operating System. On Linux
you can also easily see what calls are made into the OS. run, strace
java -cp . Hello
(On Solaris and some other Unixes this is called "truss"). It will
then print out all the calls made into the OS layer. Neato!

If you need that then you have a classpath environment variable set that
you shouldn't have set.
 
K

Knute Johnson

Hi
I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
public static void main( String[] args )
{
System.out.println( "Hello, World!" );
}
}
On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
What else must I do to simply get the Hello World message?
Regards
Did you compile it first? Do you have the compiler installed?

javac Hello.java

creates the Hello.class file. Then you type

java Hello

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Hi

I cannot use the javac command. I dont´have it on my system. I do have
the full install of JDK on my machine<

When you install the JDK on Windows it installs the compiler as well but
doesn't set up the path so you can run it. You need to get the System
Properties dialog up and select the Advanced tab, press the Environment
Variables button (at the bottom) and then add to either PATH, C:\Program
Files\JDK1.6.0_07\bin. Start a new Command Prompt, then compile and run
your program.

Depending on which version of windows you have the System Properties
dialog can be hard to find. On my XP system it is Start, Control Panel,
Performance and Maintenance then System.
 
K

Knute Johnson

Knute said:
(e-mail address removed) wrote:
Hi
I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
public static void main( String[] args )
{
System.out.println( "Hello, World!" );
}
}
On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
What else must I do to simply get the Hello World message?
Regards
Did you compile it first? Do you have the compiler installed?

javac Hello.java

creates the Hello.class file. Then you type

java Hello

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access-
Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Hi

I cannot use the javac command. I dont´have it on my system. I do have
the full install of JDK on my machine<

When you install the JDK on Windows it installs the compiler as well but
doesn't set up the path so you can run it. You need to get the System
Properties dialog up and select the Advanced tab, press the Environment
Variables button (at the bottom) and then add to either PATH, C:\Program
Files\JDK1.6.0_07\bin. Start a new Command Prompt, then compile and run
your program.

Depending on which version of windows you have the System Properties
dialog can be hard to find. On my XP system it is Start, Control Panel,
Performance and Maintenance then System.

Sorry that should be; C:\Program Files\Java\JDK1.6.0_07\bin
 
M

mil_ant

(e-mail address removed) wrote:
Hi
I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
    public static void main( String[] args )
    {
        System.out.println( "Hello, World!" );
    }
}
 On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
What else must I do to simply get the Hello World message?
Regards
Did you compile it first?  Do you have the compiler installed?
javac Hello.java
creates the Hello.class file.  Then you type
java Hello
--
Knute Johnson
email s/nospam/knute2008/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
             ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -

I cannot use the javac command. I dont´have it on my system. I do have
the full install of JDK on my machine<

When you install the JDK on Windows it installs the compiler as well but
doesn't set up the path so you can run it.  You need to get the System
Properties dialog up and select the Advanced tab, press the Environment
Variables button (at the bottom) and then add to either PATH, C:\Program
Files\JDK1.6.0_07\bin.  Start a new Command Prompt, then compile and run
your program.

Depending on which version of windows you have the System Properties
dialog can be hard to find.  On my XP system it is Start, Control Panel,
Performance and Maintenance then System.

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
             ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Hi Knut,

At compilation I get the error :
C:\Documents and Settings\Administrator>javac Hello
'javac' is not recognized as an internal or external command,
operable program or batch file.

I have fully installed the latest version of JDK.

Regards
 
K

Knute Johnson

On 17 okt, 18:10, Knute Johnson <[email protected]>
wrote:
(e-mail address removed) wrote:
Hi
I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
public static void main( String[] args )
{
System.out.println( "Hello, World!" );
}
}
On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
What else must I do to simply get the Hello World message?
Regards
Did you compile it first? Do you have the compiler installed?
javac Hello.java
creates the Hello.class file. Then you type
java Hello
--
Knute Johnson
email s/nospam/knute2008/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -
Hi
I cannot use the javac command. I dont´have it on my system. I do have
the full install of JDK on my machine<
When you install the JDK on Windows it installs the compiler as well but
doesn't set up the path so you can run it. You need to get the System
Properties dialog up and select the Advanced tab, press the Environment
Variables button (at the bottom) and then add to either PATH, C:\Program
Files\JDK1.6.0_07\bin. Start a new Command Prompt, then compile and run
your program.

Depending on which version of windows you have the System Properties
dialog can be hard to find. On my XP system it is Start, Control Panel,
Performance and Maintenance then System.

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Hi Knut,

At compilation I get the error :
C:\Documents and Settings\Administrator>javac Hello
'javac' is not recognized as an internal or external command,
operable program or batch file.

I have fully installed the latest version of JDK.

Regards

You need to set the path. Please look at my previous post.
 
M

mil_ant

(e-mail address removed) wrote:
On 17 okt, 18:10, Knute Johnson <[email protected]>
wrote:
(e-mail address removed) wrote:
Hi
I have created a file called Hello.java on my machine.This is the
content of that file:
public class Hello
{
    public static void main( String[] args )
    {
        System.out.println( "Hello, World!" );
    }
}
 On my machine I have this java version
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)
When I type java Hello in my command console I receive this message:
C:\Documents and Settings\Administrator>java Hello
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)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
What else must I do to simply get the Hello World message?
Regards
Did you compile it first?  Do you have the compiler installed?
javac Hello.java
creates the Hello.class file.  Then you type
java Hello
--
Knute Johnson
email s/nospam/knute2008/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
             ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -
Hi
I cannot use the javac command. I dont´have it on my system. I do have
the full install of JDK on my machine<
When you install the JDK on Windows it installs the compiler as well but
doesn't set up the path so you can run it.  You need to get the System
Properties dialog up and select the Advanced tab, press the Environment
Variables button (at the bottom) and then add to either PATH, C:\Program
Files\JDK1.6.0_07\bin.  Start a new Command Prompt, then compile and run
your program.
Depending on which version of windows you have the System Properties
dialog can be hard to find.  On my XP system it is Start, Control Panel,
Performance and Maintenance then System.
--
Knute Johnson
email s/nospam/knute2008/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
             ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Tekst uit oorspronkelijk bericht niet weergeven -
- Tekst uit oorspronkelijk bericht weergeven -
At compilation I get the error :
C:\Documents and Settings\Administrator>javac Hello
'javac' is not recognized as an internal or external command,
operable program or batch file.
I have fully installed the latest version of JDK.

You need to set the path.  Please look at my previous post.

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
             ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access- Tekst uit oorspronkelijk bericht niet weergeven -

- Tekst uit oorspronkelijk bericht weergeven -

Hi

I have set the bin directory in the PATH variable. I have opened a new
command window and typed javac Hello.java
This gives me the next message:
'javac' is not recognized as an internal or external command,
operable program or batch file.

I have searched for the javac executable on my system but could not
find it. How can I get this executable?

Regards
 
P

Patricia Shanahan

I have searched for the javac executable on my system but could not
find it. How can I get this executable?
....

Are you *sure* you installed a JDK, not a JRE? The symptoms you
describe, being able to run java but no javac executable on your system,
are typical of only having a JRE.

The difference is that the JDK includes javac and other files that are
needed to compile Java programs. A JRE only includes the run time support.

Patricia
 
M

mil_ant

Which bin directory, precisely?



If it wasn't in the bin directory, then you should not have included the bin
directory in the PATH.  It would behoove you to check *before* modifying the PATH.

You get the javac executable from
<http://java.sun.com/>
assuming you want Sun's version.  Look on the right where the heading says,
"Popular Downloads".  Click on the link for "Java SE".  On the new page click
on the "Download" link for "JDK 6 Update 10".  Select your "Platform", agree
to the license agreement, and click "Continue".  Click on the installer for
your platform, download it, and run it to install the JDK.  The Windows
installer lets you choose the target directory for the JDK.  The 'bin/'
subdirectory of that target directory is where the compiler executable installs.

Hi

Thank you, Thank you, Thank you all for the tips and info.

I finally get the java file running. I took the jdk 6 Update 10 and
that did the job.

Kind Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top