DZone Forums
Go Back   DZone Forums > Community > Tools & IDEs > Eclipse
Reload this Page Eclipse setup problem
Notices
Reply
 
LinkBack Thread Tools Display Modes
  (#1 (permalink)) Old
Member
 
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Apr 2009
Default Eclipse setup problem - 04-02-2009, 12:29 AM

The console below is always null, where would be the problem? Only when I am in eclipse, I can run the application properly with java MainDocument

Code:
import java.io.Console;
import java.sql.SQLException;


public class MainDocument {
  public static void main(String[] args) throws ClassNotFoundException, SQLException {
    Console console = System.console();
    if (console == null) {
      System.err.println("sales: unable to obtain console");
      return;
    }

    console.printf("%s ", "string");
  }
}
result=> sales: unable to obtain console


I have set the path X:\Sun\sdk\jdk\bin to no avail.
I guess there is something wrong with classpath or whatsoever... but not sure how to setup.... could anyone help me out?
Any suggestions?
Jack
Reply With Quote
  (#2 (permalink)) Old
Moderator
 
Posts: 102
Thanks: 0
Thanked 7 Times in 7 Posts
Join Date: Jan 2008
Default 04-02-2009, 03:59 AM

I'm not sure if that's an Eclipse problem. From reading Console (Java Platform SE 6) it seems it will return null if no console device is available.

James
Reply With Quote
  (#3 (permalink)) Old
Member
 
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Apr 2009
Default 04-02-2009, 04:06 AM

Hi James,

Quote:
Originally Posted by jsugrue View Post
I'm not sure if that's an Eclipse problem. From reading Console (Java Platform SE 6) it seems it will return null if no console device is available.

James
Thanks for your reply. What strange to me is that I can't run/debug all applications as "Debug as Application" that used to run fine before I re-install xp, some can be run using "debug as applet"..... The console thing is okay when I run on the command prompt..... but maybe you're right
Thanks
Jack
Reply With Quote
  (#4 (permalink)) Old
Moderator
 
Posts: 102
Thanks: 0
Thanked 7 Times in 7 Posts
Join Date: Jan 2008
Default 04-02-2009, 06:32 AM

I wonder if you've got the same JRE/JDK setup in Eclipse that you are using on the command line?
Reply With Quote
  (#5 (permalink)) Old
Member
 
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Apr 2009
Default 04-02-2009, 06:38 AM

Hi James,

Quote:
Originally Posted by jsugrue View Post
I wonder if you've got the same JRE/JDK setup in Eclipse that you are using on the command line?
I have been trying the settings all night. But this is very discouraging, I couldn't achieve anything... What settings can I look into?
Thanks in advance
Jack
Reply With Quote
  (#6 (permalink)) Old
Moderator
 
Posts: 102
Thanks: 0
Thanked 7 Times in 7 Posts
Join Date: Jan 2008
Default 04-02-2009, 06:42 AM

Check Window/Preferences/Java/Installed JREs and check that the JRE that you are using is the same as that on the command line.

I'm going to try this out from my own machine now and will let you know
James
Reply With Quote
  (#7 (permalink)) Old
Moderator
 
Posts: 102
Thanks: 0
Thanked 7 Times in 7 Posts
Join Date: Jan 2008
Default 04-02-2009, 06:42 AM

Check Window/Preferences/Java/Installed JREs and check that the JRE that you are using is the same as that on the command line.

I'm going to try this out from my own machine now and will let you know
James
Reply With Quote
  (#8 (permalink)) Old
Moderator
 
Posts: 102
Thanks: 0
Thanked 7 Times in 7 Posts
Join Date: Jan 2008
Default 04-02-2009, 06:47 AM

Hey Jack

Well it looks like it can't work in Eclipse - I tried it, got the same as you, and read about it:

EclipseZone - System.console() doesn't in Eclipse ...

So, you won't be able to use the Console inside Eclipse, but when you deploy this program outside of Eclipse, it should work fine.

Maybe you can work around this and use some approach other than Console?

At least this puts an end to your searching :-)

James
Reply With Quote
  (#9 (permalink)) Old
Moderator
 
Posts: 102
Thanks: 0
Thanked 7 Times in 7 Posts
Join Date: Jan 2008
Default 04-02-2009, 06:47 AM

Hey Jack

Well it looks like it can't work in Eclipse - I tried it, got the same as you, and read about it:

EclipseZone - System.console() doesn't in Eclipse ...

So, you won't be able to use the Console inside Eclipse, but when you deploy this program outside of Eclipse, it should work fine.

Maybe you can work around this and use some approach other than Console?

At least this puts an end to your searching :-)

James
Reply With Quote
  (#10 (permalink)) Old
Member
 
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Join Date: Apr 2009
Default 04-02-2009, 06:50 AM

Quote:
Originally Posted by jsugrue View Post
Check Window/Preferences/Java/Installed JREs and check that the JRE that you are using is the same as that on the command line.

I'm going to try this out from my own machine now and will let you know
James
It is called jre1.60_06....
The zip file I have is java_ee_sdk-5_04-windows
And also how can I tell which version I am using on the command prompt?
Thanks
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error in setting alfresco SDK setup with eclipse madhu25 Eclipse 0 03-23-2009 02:44 AM
Moving my Eclipse PDT setup? esender Eclipse 0 12-17-2008 11:22 PM
Problem with JRE compatibility using Eclipse Maverickk Eclipse 1 12-03-2008 05:56 AM
eclipse CDT import problem. ruony Eclipse 0 07-04-2008 01:29 AM
Ant-editors problem in eclipse 3.3.1.1 Ashkan Eclipse 2 04-03-2008 10:26 AM


Copyright 1997-2009, DZone, Inc.
vBulletin Skin developed by: vBStyles.com