LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-10-2003, 11:19 AM   #1
Travis86
Member
 
Registered: Dec 2002
Location: The land of GMT -6
Distribution: OS X, PS2 Linux, Ubuntu, IRIX 6.5
Posts: 399

Rep: Reputation: 31
Can't get Java to work and don't know if I should persue it.


I don't know if this should be two threads or not, but I'm making it one.

First I got the Java SDK 1.4.2 and installed it (on Windows, BTW) and now I'm trying to get my first program to work. I copied it right out of my book, Learning Java (from O'Reilly), and it is as follows:

Code:
public class Pre {
    public static void main( String[] args ) {
	System.out.println("Hi, everyone.");
    }
}
I run "C:\j2sdk1.4.2_02\bin\javac Pre.java" and it works (I haven't bothered to set the path to include the Java bin directory). When I run "C:\j2sdk1.4.2_02\bin\java Pre" it thinks for a while and says "Exception in thread "main" java.lang.NoClassDefFoundError: Pre/Java". Can anyone tell me what's going wrong here?

Also, in Learning Java, the author seems to think that Java is the greatest thing ever. I assume he's a bit biased, but I figured I'd find out whether this was true on my own.

I was using NetBeans, which was written entirely in Java, and I don't think I've ever used a slower program in my life. From what I understand of Java, the JVM code is being compiled "Just In Time." My diagnosis for NetBeans is that it's a decent program in need of good, old-fashioned compiling. I know I don't have a fast computer, but Photoshop runs twice as fast as NetBeans. Every time that I would go to another program and come back to NetBeans the hard drive would go into overdrive and it would freeze. Even during normal use the hard drive hardly ever stopped cranking. And nothing ran smoothly.

Is Java really all its supposed to be?
 
Old 12-10-2003, 01:55 PM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
You might have to add the current directory to your CLASSPATH. Try either adding ./ to your CLASSPATH environment variable, or find out what the command-line option is to add a CLASSPATH directory. I believe the parameter for that was -cp...

About the slowness of the IDE. I've noticed that myself. Not only with the NetBeans IDE, but also with Borland's IDE, which is also written in Java. That's just one of the reasons I generally don't develop stuff in Java myself.

Last edited by deiussum; 12-10-2003 at 01:57 PM.
 
Old 12-10-2003, 09:48 PM   #3
Travis86
Member
 
Registered: Dec 2002
Location: The land of GMT -6
Distribution: OS X, PS2 Linux, Ubuntu, IRIX 6.5
Posts: 399

Original Poster
Rep: Reputation: 31
That was the problem, alright! Works like a charm now. Well, like a slow charm, anyway.

I found that the Java part of the GCC will compile Java right into machine code (see http://gcc.gnu.org/java/). I think that's probably the way to go, although it's against almost everything Sun wants Java to be. I guess they'll have to get over it.
 
Old 12-11-2003, 09:49 AM   #4
memory_leak
LQ Newbie
 
Registered: Dec 2003
Posts: 24

Rep: Reputation: 15
Code:
That was the problem, alright! Works like a charm now. Well, like a slow charm, anyway.

I found that the Java part of the GCC will compile Java right into machine code (see http://gcc.gnu.org/java/). I think that's probably the way to go, although it's against almost everything Sun wants Java to be. I guess they'll have to get over it.

oh man - let's be hones: you can't see speed difference in byte compiled code and machine code when you run THAT program

ofcourse is java slower than machine code - but you need a way muuuuch more compilacated applications to see that difference
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java won't work nibbler Fedora 4 09-08-2005 09:20 PM
getting java to work. meeep Ubuntu 1 08-21-2005 09:10 AM
Java Plug-in will not work aaronruss Linux - Newbie 8 12-19-2004 07:47 PM
Updated Java... now java apps dont work zidane2010 Linux - Software 6 05-04-2004 08:02 PM
Getting Java to work!!!! kkj Linux - Newbie 1 04-09-2004 01:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:32 AM.

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