473,327 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Why do the outputs differ when I run this code using Netbeans 6.8 and Eclipse?

108 100+
When I am running the following codes using Eclipse and Netbeans 6.8. I want to see the available COM ports on my computer. When running in Eclipse it is returning me all available COm ports but when running t in Netbeans, it does not seem to find any ports ..

Expand|Select|Wrap|Line Numbers
  1. public static void test(){
  2.  
  3.         Enumeration lists=CommPortIdentifier.getPortIdentifiers();
  4.  
  5.             System.out.println(lists.hasMoreElements());
  6.             while (lists.hasMoreElements()){
  7.                 CommPortIdentifier cn=(CommPortIdentifier)lists.nextElement();
  8.  
  9.                 if ((CommPortIdentifier.PORT_SERIAL==cn.getPortType())){
  10.                     System.out.println("Name is serail portzzzz "+cn.getName()+" Owned status "+cn.isCurrentlyOwned());
  11.  
  12.                     try{
  13.                         SerialPort port1=(SerialPort)cn.open("ComControl",800000);
  14.                         port1.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
  15.                         System.out.println("Before get stream");
  16.                         OutputStream out=port1.getOutputStream();
  17.                         InputStream input=port1.getInputStream();
  18.                         System.out.println("Before write");
  19.                         out.write("AT".getBytes());
  20.                         System.out.println("After write");
  21.                         int sample=0;
  22.                         //while((( sample=input.read())!=-1)){
  23.                         System.out.println("Before read");
  24.                             //System.out.println(input.read() + "TEsting ");
  25.                         //}
  26.                             System.out.println("After read");
  27.                         System.out.println("Receive timeout is "+port1.getReceiveTimeout());
  28.                     }catch(Exception e){
  29.                         System.err.println(e.getMessage());
  30.                     }
  31.                 }
  32.  
  33.                 else{
  34.                     System.out.println("Name is parallel portzzzz "+cn.getName()+" Owned status "+cn.isCurrentlyOwned()+cn.getPortType()+"    ");
  35.                 }
  36.             }
  37.  
  38.     }
  39.  
  40.  
  41.  
  42.  
Output with Netbeans

false




Output using Eclipse

true
Name is serail portzzzz COM1 Owned status false
Before get stream
Before write
After write
Before read
After read
Receive timeout is -1
Name is serail portzzzz COM2 Owned status false
Before get stream
Before write
After write
Before read
After read
Receive timeout is -1
Name is parallel portzzzz LPT1 Owned status false2
Name is parallel portzzzz LPT2 Owned status false2
Dec 26 '10 #1
0 1027

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Eduardo Hercos Rodrigues | last post by:
Hi, How to print directly from PHP code using CUPS? Thanks, "Eduardo Hercos Rodrigues"
0
by: Error while executing SP | last post by:
Hi, I am getting an error while executing a sp from Oracle database. Can you let me know what could be the problem? here is the code using(System.Data.OleDb.OleDbConnection cn = new...
2
by: Jim M | last post by:
I hate to pass data on the query string. Is there a way to pass data to the serverside vb code using the object in showmodaldialog. var myObject = new Object(); var retVal = new Object();...
2
by: Umpty | last post by:
Trying to use Microsoft Indexing Service. Here is my code using SQL Query Analyzer, which works perfectly. SELECT * FROM OPENQUERY(FileSystem, 'SELECT RANK, FileName, Characterization FROM...
1
by: Chaitanya | last post by:
please tell me ,the tld files like struts-bean.tld, struts-html.tld, struts-logic.tld are generated automatically or done by ourselves using Netbeans. As they are automatically generated in...
0
by: ApexData | last post by:
I have a Split Database. FE / BE. It has been working fine, on a server for months. The BE exists in a secure folder used by 5 users who have full rights to the application. A number of other...
1
myusernotyours
by: myusernotyours | last post by:
hi all, Am building an desktop app that needs to access a mysql database and am using netbeans 6 can someone direct me to a good tutorial that shows how this can be done?
0
by: =?Utf-8?B?S2luZXRpYyBKdW1wIEFwcGxpZmUgZm9yIC5ORVQg | last post by:
Refactor .NET code using Visual Studio and Refactor! Pro Modifying the existing source code without changing its functionality is called refactoring of Source Code. Visual Studio gives us a lots of...
1
atksamy
by: atksamy | last post by:
Hi, I have a form with a few buttons which execute code when pressed like running validations on the database. some of these code could could run for a few minutes so is there any way to show the...
0
by: arahmoun | last post by:
I am developing a Dbase application in a mobile environment using NetBeans. I created tables that cannot be displayed. I am also using MySql for Data connect. Please tell me how to make these tables...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.