Jump to content

One man, One Mission


Machstorm
 Share

Recommended Posts

I don't know what it was today, but I made up my mind and I'm going to dust off the books I bought a year ago and learn Java. I am going to start tonight and see if I can do it by this time tomorrow.

Here's the book I will be using:

http://www.mhprofessional.com/product.php?...isbn=0078825709

along with this book by Cisco:

http://www.amazon.com/Fundamentals-Program...pd_bxgy_b_img_a

Time to breakout the Caffine

Link to comment
Share on other sites

One problem that I am running into is that I cannot run complied source code from a command line when I create it from Netbeans 6.5.

Netbeans shows the correct output for

public class Example2 {

public static void main (String args[]) {

System.out.println("This is the first line");

System.out.println ("This is the secondline");

}

}

But when I go to the folder that holds the class file for Example2 and run it from the command line I get this:

ld\classes\example2>java Example2

Exception in thread "main" java.lang.NoClassDefFoundError: Example2 (wrong name:

example2/Example2)

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.defineClass(Unknown Source)

at java.net.URLClassLoader.access$000(Unknown Source)

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)

Could not find the main class: Example2. Program will exit.

Is there something I missed?

Link to comment
Share on other sites

Oh, ok I will try that. Thanks

(Edit) I got it to work finally. I had to tell Netbeans to create and store the Jar file so I could use it But I cannot acces it directly I have ti use this command to do it.

java -jar "C:\Documents and Settings\Home_Directory\My Documents\NetBeansProjects\Example1\dist\Example1.jar"

Otherwise, I get an error.

Link to comment
Share on other sites

Yeah javas a pain to start with. I can remember getting a hello world program working on its own (actually manged to compile the jar :)) awhile back but I'm much happier with .net now. Not saying I don't want to learn java, its just vb + the fact it was a class I took very seriously = got somewhere a lot faster than trying to learn on my own. This though took me a good 5-6 months and I'm still learning, so don't expect to learn it using the 1-3 week strategy.

GL whatever path you take.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...