Having problem with Java Communication API

I am using this code to list the port that i have but it does not return any thing. when i compile and run nothing is printed out. i think either its not going in while loop but if i remove while loop it returns NULL. so i think its not recognizing any PORTS. i want to detect a modem port as i want to make a voice mail software. I am jsut starting by listing, opening and listening to the ports. Please help me ASAP. Thank you.
import javax.comm.*;
import java.util.*;
public class PortLister {
public static void main(String[] args) {
Enumeration e = CommPortIdentifier.getPortIdentifiers();
while (e.hasMoreElements()) {
System.out.println((CommPortIdentifier) e.nextElement());
}

Go back where you downloaded the API and read the FAQ. I think it's the question number 2.

Similar Messages

  • Problem with java communication api for gsm modem port

    Hi,every body
        Am using gsm modem in my project previously my linux is 32bit with 32 bit jvm of sun that time there was no problem at the time of working with gsm modem port .But now am using 64bit linux then 32bit files are not supporting to communicate with gsm modem port .How can i get java communication api for unix 64bit ,64bit jvm of sun.please any body help me ...i am searching in sun/oracle also for downloading java communication files of 64bit jvm but i didn't get the link... i need bellow java communication api files.
           ex:1)libLinuxSerialParallel.so
                2)javax.comm.properties
                3)comm.jar
                4)commtest.jar

    Moderator Action:
    This duplicate cross-post is locked.
    Stay with your original post.
    https://forums.oracle.com/thread/2602063
    (... and your hijack reply to a third thread has been removed.)

  • Problem with Java Communication API

    hi
    I installed the Java Communication API on win32 platform (as per the guidelines)
    Now when I try to run the sample program 'Blackbox' for the serial port, I get an error (in fact an exception is generated inside main function in BlackBox.class file)
    I tried the SimpleRead.java example but that too generated the same exception
    Can anybody help me out.... I am a novice with Java Comm API

    I tried running the sample BlackBox program provided for serial port and now it says
    No Serial Ports Found!
    I verified that both comm.jar and javax.comm.properties are in the <JDK>\lib directory.
    Actually, I am using netBeans IDE 1.4 and I used the C:\J2SDK folder installed with netBeans for the Java Communicaion API
    plz help.

  • Our school is having problems with Java.

    Our school is having problems with Java.  We cannot open our gradebooks which require jnlp or java to open.  They worked until January 31 and then quit.  I uploaded the Java from oracle but it doesn't open anything it just keeps running.  Any ideas?

    See  Java for OS X 2012-006: How to re-enable the Apple-provided Java SE 6 applet plug-in and Web Start functionality. That might be what you need, not Java 7.

  • Problems with Java Scripting API

    Hello Everyone!
    Guys, I need help with Java scripting API. A problem is that I cannot understand how can I operate Java Object's fields and methods from the script language. I have chosen embedded javascript to work with. And I can get the fields and methods of in-box java classes (such as ArrayList for example), but I cannot work with methods and fields from my own classes!
    Here is an example:
    public class ScriptingExample {  
        class MyClass {  
            int myfield = 5;  
            int getInt() {return 7;}  
        public void runExample() {  
            ScriptEngineManager mgr = new ScriptEngineManager();  
            List<ScriptEngineFactory> factories = mgr.getEngineFactories();  
            ScriptEngineManager factory = new ScriptEngineManager();  
            ScriptEngine engine = factory.getEngineByName("JavaScript");  
            MyClass mc = new MyClass();  
            try{  
                engine.put("mc", mc);  
                engine.eval("print(mc.myfield); print(mc.getInt())"); // or engine.eval("print(mc.myfield)");
            } catch (Exception e) {e.printStackTrace();}  
    }  If I run the code with the commented part it prints "undefined" instead of "5".
    If I run the code as it is it prints error instead of "7":
    undefinedjavax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function getInt. (<Unknown source>#1) in <Unknown source> at line number 1
    at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
    at com.sun.script.javascript.RhinoScriptEngine.eval(Unknown Source)
    at javax.script.AbstractScriptEngine.eval(Unknown Source)
    at solutiondatabase.ScriptingExample.runExample(ScriptingExample.java:26)
    at solutiondatabase.Main.main(Main.java:49)
    How can I fix it?

    Guys,
    please let me raise this topic because several new questions emerged.
    (1) How can I get all the variables created inside my engine?
    There are two kinds of variables: first kind is Java obejcts put inside the engine and second kind is the variables created in my script, such as 'var a = 4;'. How can I list all the variables of that two kinds?
    (2) Is there is a way to make 'import static' to the engine? I dont want to write MyClass.MyEnum.MyEnumItem every time. Also, I cannot put the whole enum into the engine with engine.put("MyEnum", MyEnum); I can put only enum items separately: engine.put("MyEnum", MyEnum.EnumItemA);. Thats why I ask about static import.
    (3) How can I cast engine variables back to java variables inside my java code?
    Here is my example:
    package mypackage;
    import java.util.ArrayList;
    import java.util.List;
    import javax.script.ScriptEngine;
    import javax.script.ScriptEngineFactory;
    import javax.script.ScriptEngineManager;
    public class Main
         public static void main(String[] args) throws Exception 
              ScriptEngineManager mgr = new ScriptEngineManager();
              List<ScriptEngineFactory> factories = mgr.getEngineFactories();
              ScriptEngineManager factory = new ScriptEngineManager();
              ScriptEngine engine = factory.getEngineByName("JavaScript");
              ArrayList<Double> myList = new ArrayList<Double>();
              myList.add(5.0);                    
              engine.put("MyList", myList);     
              engine.eval("MyVar = MyList.get(0);");
              System.out.println((Double)engine.get("MyVar"));
    }The result is:
    Exception in thread "main" java.lang.ClassCastException: sun.org.mozilla.javascript.internal.NativeJavaObject cannot be cast to java.lang.Double
    +     at mypackage.Main.main(Main.java:28)+
    Is it possible to retrieve my Double java object from the engine?
    Edited by: Dmitry_MSK on Aug 6, 2010 1:56 AM

  • Having problems with java and website

    Can anyone help with a problem I am having using a Java Chat application on a website?
    I have tried to use Java Chat and the applet, when clicking the "private message" link, takes a long time to open up, and locks up my computer when it is doing so.
    I did download the latest version of Java to my computer and this problem exists using both the Netscape and Internet Explorer latest browsers.
    I am using Windows XP on a Dell Computer with a DSL connection.
    The website is http://www.gay.com/chat
    I did get an error message one time that saved a file to my desktop.
    Can anyone advise me what is going on?
    Any help would be greatly appreciated.
    I have contacted technical support at http://www.gay.com to no avail.
    Please write me back directly to [email protected]
    Here is the code which I am not sure has anything to do with the problem or not:
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x6D07014F
    Function=Java_sun_awt_windows_WColor_getDefaultColor+0x28D4
    Library=C:\Program Files\Java\j2re1.4.1_02\bin\awt.dll
    Current Java thread:
         at sun.awt.windows.WToolkit.eventLoop(Native Method)
         at sun.awt.windows.WToolkit.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Dynamic libraries:
    0x00400000 - 0x00419000      C:\Program Files\Internet Explorer\IEXPLORE.EXE
    0x77F50000 - 0x77FF7000      C:\WINDOWS\System32\ntdll.dll
    0x77E60000 - 0x77F46000      C:\WINDOWS\system32\kernel32.dll
    0x77C10000 - 0x77C63000      C:\WINDOWS\system32\msvcrt.dll
    0x77D40000 - 0x77DC6000      C:\WINDOWS\system32\USER32.dll
    0x77C70000 - 0x77CB0000      C:\WINDOWS\system32\GDI32.dll
    0x77DD0000 - 0x77E5D000      C:\WINDOWS\system32\ADVAPI32.dll
    0x78000000 - 0x7807F000      C:\WINDOWS\system32\RPCRT4.dll
    0x70A70000 - 0x70AD4000      C:\WINDOWS\system32\SHLWAPI.dll
    0x71700000 - 0x71849000      C:\WINDOWS\System32\SHDOCVW.dll
    0x71950000 - 0x71A34000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.10.0_x-ww_f7fb5805\comctl32.dll
    0x773D0000 - 0x77BC2000      C:\WINDOWS\system32\SHELL32.dll
    0x77340000 - 0x773CB000      C:\WINDOWS\system32\comctl32.dll
    0x771B0000 - 0x772D1000      C:\WINDOWS\system32\ole32.dll
    0x5AD70000 - 0x5ADA4000      C:\WINDOWS\System32\uxtheme.dll
    0x75F80000 - 0x7607C000      C:\WINDOWS\System32\BROWSEUI.dll
    0x72430000 - 0x72442000      C:\WINDOWS\System32\browselc.dll
    0x75F40000 - 0x75F5F000      C:\WINDOWS\system32\appHelp.dll
    0x76FD0000 - 0x77048000      C:\WINDOWS\System32\CLBCATQ.DLL
    0x77120000 - 0x771AB000      C:\WINDOWS\system32\OLEAUT32.dll
    0x77050000 - 0x77115000      C:\WINDOWS\System32\COMRes.dll
    0x77C00000 - 0x77C07000      C:\WINDOWS\system32\VERSION.dll
    0x76200000 - 0x76298000      C:\WINDOWS\system32\WININET.dll
    0x762C0000 - 0x76348000      C:\WINDOWS\system32\CRYPT32.dll
    0x762A0000 - 0x762AF000      C:\WINDOWS\system32\MSASN1.dll
    0x76F90000 - 0x76FA0000      C:\WINDOWS\System32\Secur32.dll
    0x76620000 - 0x7666E000      C:\WINDOWS\System32\cscui.dll
    0x76600000 - 0x7661B000      C:\WINDOWS\System32\CSCDLL.dll
    0x76670000 - 0x76757000      C:\WINDOWS\System32\SETUPAPI.dll
    0x10000000 - 0x1001C000      C:\Program Files\Norton SystemWorks\Norton AntiVirus\NavShExt.dll
    0x01470000 - 0x0148A000      C:\WINDOWS\System32\ccTrust.dll
    0x55900000 - 0x55961000      C:\WINDOWS\System32\MSVCP60.dll
    0x76B20000 - 0x76B35000      C:\WINDOWS\System32\ATL.DLL
    0x014D0000 - 0x016D1000      C:\WINDOWS\System32\msi.dll
    0x016E0000 - 0x01704000      C:\Program Files\Microsoft Money\System\mnyviewer.dll
    0x763B0000 - 0x763F5000      C:\WINDOWS\system32\comdlg32.dll
    0x1A400000 - 0x1A47A000      C:\WINDOWS\system32\urlmon.dll
    0x76170000 - 0x761F8000      C:\WINDOWS\System32\shdoclc.dll
    0x74770000 - 0x747FF000      C:\WINDOWS\System32\mlang.dll
    0x71AD0000 - 0x71AD8000      C:\WINDOWS\System32\wsock32.dll
    0x71AB0000 - 0x71AC5000      C:\WINDOWS\System32\WS2_32.dll
    0x71AA0000 - 0x71AA8000      C:\WINDOWS\System32\WS2HELP.dll
    0x71A50000 - 0x71A8B000      C:\WINDOWS\system32\mswsock.dll
    0x71A90000 - 0x71A98000      C:\WINDOWS\System32\wshtcpip.dll
    0x76EE0000 - 0x76F17000      C:\WINDOWS\System32\RASAPI32.DLL
    0x76E90000 - 0x76EA1000      C:\WINDOWS\System32\rasman.dll
    0x71C20000 - 0x71C6E000      C:\WINDOWS\System32\NETAPI32.dll
    0x76EB0000 - 0x76EDB000      C:\WINDOWS\System32\TAPI32.dll
    0x76E80000 - 0x76E8D000      C:\WINDOWS\System32\rtutils.dll
    0x76B40000 - 0x76B6C000      C:\WINDOWS\System32\WINMM.dll
    0x5CD70000 - 0x5CD77000      C:\WINDOWS\System32\serwvdrv.dll
    0x5B0A0000 - 0x5B0A7000      C:\WINDOWS\System32\umdmxfrm.dll
    0x75E90000 - 0x75F37000      C:\WINDOWS\System32\SXS.DLL
    0x76F20000 - 0x76F45000      C:\WINDOWS\System32\DNSAPI.dll
    0x76D60000 - 0x76D77000      C:\WINDOWS\System32\iphlpapi.dll
    0x76FB0000 - 0x76FB7000      C:\WINDOWS\System32\winrnr.dll
    0x76F60000 - 0x76F8C000      C:\WINDOWS\system32\WLDAP32.dll
    0x722B0000 - 0x722B5000      C:\WINDOWS\System32\sensapi.dll
    0x75A70000 - 0x75B15000      C:\WINDOWS\system32\USERENV.dll
    0x0FFD0000 - 0x0FFF3000      C:\WINDOWS\System32\rsaenh.dll
    0x76FC0000 - 0x76FC5000      C:\WINDOWS\System32\rasadhlp.dll
    0x63580000 - 0x6382C000      C:\WINDOWS\System32\mshtml.dll
    0x746F0000 - 0x74716000      C:\WINDOWS\System32\msimtf.dll
    0x74720000 - 0x74764000      C:\WINDOWS\System32\MSCTF.dll
    0x76390000 - 0x763AC000      C:\WINDOWS\System32\IMM32.DLL
    0x32520000 - 0x32532000      C:\Program Files\Microsoft Office\Office10\msohev.dll
    0x02430000 - 0x0244B000      C:\Program Files\Common Files\Symantec Shared\Script Blocking\scrauth.dll
    0x02560000 - 0x0257E000      C:\Program Files\Common Files\Symantec Shared\Script Blocking\ScrBlock.dll
    0x76C30000 - 0x76C5B000      C:\WINDOWS\System32\wintrust.dll
    0x76C90000 - 0x76CB2000      C:\WINDOWS\system32\IMAGEHLP.dll
    0x73D50000 - 0x73D60000      C:\WINDOWS\System32\cryptnet.dll
    0x6B700000 - 0x6B790000      c:\windows\system32\jscript.dll
    0x746C0000 - 0x746E7000      C:\WINDOWS\System32\MSLS31.DLL
    0x73300000 - 0x73375000      c:\windows\system32\vbscript.dll
    0x03380000 - 0x03509000      C:\WINDOWS\System32\macromed\flash\Flash.ocx
    0x72D20000 - 0x72D29000      C:\WINDOWS\System32\wdmaud.drv
    0x72D10000 - 0x72D18000      C:\WINDOWS\System32\msacm32.drv
    0x77BE0000 - 0x77BF4000      C:\WINDOWS\System32\MSACM32.dll
    0x77BD0000 - 0x77BD7000      C:\WINDOWS\System32\midimap.dll
    0x65000000 - 0x65009000      C:\WINDOWS\System32\ddrawex.dll
    0x51000000 - 0x51047000      C:\WINDOWS\System32\DDRAW.dll
    0x73BC0000 - 0x73BC6000      C:\WINDOWS\System32\DCIMAN32.dll
    0x6BDD0000 - 0x6BE03000      C:\WINDOWS\System32\dxtrans.dll
    0x6BE10000 - 0x6BE65000      C:\WINDOWS\System32\dxtmsft.dll
    0x74CB0000 - 0x74D1F000      C:\WINDOWS\System32\mshtmled.dll
    0x05230000 - 0x05237000      C:\Program Files\Microsoft Money\System\urlmapps.dll
    0x71B20000 - 0x71B31000      C:\WINDOWS\system32\MPR.dll
    0x75F60000 - 0x75F66000      C:\WINDOWS\System32\drprov.dll
    0x71C10000 - 0x71C1D000      C:\WINDOWS\System32\ntlanman.dll
    0x71CD0000 - 0x71CE6000      C:\WINDOWS\System32\NETUI0.dll
    0x71C90000 - 0x71CCC000      C:\WINDOWS\System32\NETUI1.dll
    0x71C80000 - 0x71C86000      C:\WINDOWS\System32\NETRAP.dll
    0x71BF0000 - 0x71C01000      C:\WINDOWS\System32\SAMLIB.dll
    0x75F70000 - 0x75F79000      C:\WINDOWS\System32\davclnt.dll
    0x75970000 - 0x75A61000      C:\WINDOWS\System32\MSGINA.dll
    0x76360000 - 0x7636F000      C:\WINDOWS\System32\WINSTA.dll
    0x1F7B0000 - 0x1F7E1000      C:\WINDOWS\System32\ODBC32.dll
    0x1F850000 - 0x1F866000      C:\WINDOWS\System32\odbcint.dll
    0x767F0000 - 0x76814000      C:\WINDOWS\System32\schannel.dll
    0x0FFA0000 - 0x0FFC1000      C:\WINDOWS\System32\dssenh.dll
    0x66E50000 - 0x66E8B000      C:\WINDOWS\System32\iepeers.dll
    0x73000000 - 0x73023000      C:\WINDOWS\System32\WINSPOOL.DRV
    0x71D40000 - 0x71D5B000      C:\WINDOWS\System32\actxprxy.dll
    0x6CC60000 - 0x6CC6B000      C:\WINDOWS\System32\dispex.dll
    0x6D820000 - 0x6D82F000      C:\Program Files\Java\j2re1.4.1_02\bin\npjpi141_02.dll
    0x6D780000 - 0x6D796000      C:\Program Files\Java\j2re1.4.1_02\bin\jpiexp32.dll
    0x6D7C0000 - 0x6D7D4000      C:\Program Files\Java\j2re1.4.1_02\bin\jpishare.dll
    0x6D340000 - 0x6D46A000      C:\PROGRA~1\Java\J2RE14~1.1_0\bin\client\jvm.dll
    0x6D1E0000 - 0x6D1E7000      C:\PROGRA~1\Java\J2RE14~1.1_0\bin\hpi.dll
    0x6D310000 - 0x6D31E000      C:\PROGRA~1\Java\J2RE14~1.1_0\bin\verify.dll
    0x6D220000 - 0x6D239000      C:\PROGRA~1\Java\J2RE14~1.1_0\bin\java.dll
    0x6D330000 - 0x6D33D000      C:\PROGRA~1\Java\J2RE14~1.1_0\bin\zip.dll
    0x6D000000 - 0x6D105000      C:\Program Files\Java\j2re1.4.1_02\bin\awt.dll
    0x6D190000 - 0x6D1E0000      C:\Program Files\Java\j2re1.4.1_02\bin\fontmanager.dll
    0x5C000000 - 0x5C0C8000      C:\WINDOWS\System32\D3DIM700.DLL
    0x6D720000 - 0x6D731000      C:\Program Files\Java\j2re1.4.1_02\bin\jpicom32.dll
    0x6D2E0000 - 0x6D2EE000      C:\Program Files\Java\j2re1.4.1_02\bin\net.dll
    0x6D140000 - 0x6D162000      C:\Program Files\Java\j2re1.4.1_02\bin\dcpr.dll
    0x67F00000 - 0x67F07000      C:\Program Files\America Online 8.0\idleproc.dll
    0x05420000 - 0x05427000      C:\Program Files\Yahoo!\Messenger\idle.dll
    0x1FCF0000 - 0x1FFBE000      C:\WINDOWS\System32\wmploc.dll
    0x732E0000 - 0x732E5000      C:\WINDOWS\System32\RICHED32.DLL
    0x74E30000 - 0x74E9A000      C:\WINDOWS\System32\RICHED20.dll
    0x6D2B0000 - 0x6D2D1000      C:\Program Files\Java\j2re1.4.1_02\bin\jsound.dll
    0x6D290000 - 0x6D2AE000      C:\Program Files\Java\j2re1.4.1_02\bin\jpeg.dll
    0x6D510000 - 0x6D58D000      C:\WINDOWS\system32\DBGHELP.dll
    0x76BF0000 - 0x76BFB000      C:\WINDOWS\System32\PSAPI.DLL
    Local Time = Sun Apr 20 21:23:14 2003
    Elapsed Time = 30584
    # The exception above was detected in native code outside the VM
    # Java VM: Java HotSpot(TM) Client VM (1.4.1_02-b06 mixed mode)

    Having closely scrutinised your code for many hours, I am at a loss with this one. The one thing that is suspicious is the exclamation mark after Yahoo in the 8th line from the bottom.
    Get rid of it and give it a try.

  • Having problems with java

    This is mainly a problem with either the JRE or the JVM (not sure which... for some reason have both on my computer). I use Mozilla Firefox as my main browser but this same thing happens when using Netscape 7.2. Also, my OS is Windows ME. Now onto the problem: Whenever I try to load a game applet or some other java applet I usually get an error in one of these three files: JPINSCP.DLL, MSVCRT.DLL, or KERNEL32.DLL. This happens no matter the time of day and no matter what I do. I've tried uninstalling and reinstalling the V5 version of JRE to see if that would help but it hasn't. Any help with this would be appreciated.

    What error???

  • Problem with java logging API

    Hi there
    It`s the first time I`m using (I have to use) the standard java logging API.
    My need is to integrate it in an existing web-application based on struts.
    So my first step was to include the following code into an Struts Action-class:
    FileHandler file = new FileHandler("/pathToLogFile/myLogFile.log",true);
    file.setFormatter(new SimpleFormatter());
    logger.info("create info");
    By intention is to have exactly one log-file for the whole application, but indeed I'm getting multiple log-files, even for each request of one and the same Action/Servlet class, like
    myLogFile.log
    myLogFile.log.1
    myLogFile.log.2
    myLogFile.log.3
    Why does using append=true not work in the constructor of "FileHandler"
    Do I have to close the FileHandler each time I've used it?
    Is this a known issue?
    Thanks for any responds!

    @ Stone.li
    First, thanks for your answer.
    perhaps my question was quite confusing .... but my need is just
    to establish the logging API in an existing Web-Application and to have exactly one log-file for the whole application. This means I would have to provide in each servlet a FileHandler referencing to the log-file. I thought it would be part of the job of the logging API to synchronise this file access.

  • Problem with Java Print API ( awt ) : Migrated from 1.1 to 1.4

    We had migrated an application ( applet based) from Java 1.1.8 to java 1.4.
    We use the java.awt.print apis for printing data from our applications.
    There is difference in print quality after the migration. For e.g. if the data frame had a scroll bar when taken print out, the scroll bar was not visible in java1.1 version application but is being printed with java1.4 version.
    We are unable to find the cause of this problem. Any help in this regard would be of great help.
    Thanks in advance.

    Hi,
    thanks, this solved the problem.
    Thank you.
    Best regards,
    Peter

  • Updated to Snow Leopard, now having problems with Java??

    I've had my MacBookPro for five years, and I'm thrilled it's lasted so long with no bugs. However, since I updated from Tiger to Snow Leopard on my MBP, things have been running slow, hiccuping, etc. I've run the disc utility app a couple of times, and each time there is a long list of problems in the log under the categories "Applications/Utilities/AirPort Utility.app/Contents/Resources/Drives.icns", and
    "System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/management- agent.jar".
    This feels a lot like a virus. Can anyone advise? I'm real worried.
    Thanks,
    Nancy

    Nancy...  there aren't any Mac viruses.
    Your profile shows you are running v10.6.3. If that is the case, you need to update your system software to v10.6.7.
    Click your Apple menu (top left in your screen) then click Software Update.
    And check the startup disk in case it needs repairing.
    Launch Disk Utility. /Applications/Utilities. Select MacintoshHD in the panel on the left then select the First Aid tab.
    Click: Verify Disk  (not Verify Disk Permissions). if the startup disk needs repairing, follow the instructions for Using Disk Utility to verify or repair disks
    And how much free space there is on the startup disk... not enough and the drive will slow down. While you have the Disk Utility window open, at the bottom of the window see: Capacity and Available. Make sure you always have 15% free  disk space.
    Another way to keep an eye on free disk space, right or control click the MacintoshHD icon. Click Get Info. In the Get Info window you will see Capacity and Available.
    "Applications/Utilities/AirPort Utility.app/Contents/Resources/Drives.icns", and
    "System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/management- agent.jar".
    Those are just messages from verifying disk permissions. Nothing to worry about. I see the same ones.
    One key thing to remember with computers. Always backup your important files on a timely basis.

  • Having problem with java Timestamp

    Hey guys,
    I'm creating a Timestamp variable and then passing that variable to a method which is populating the Timestamp variable.
    When I get the value back its still null. Aren't all objects pass by reference? Am I missing something.
    Here is the code that I'm using
    Timestamp tStamp=null;
    boolean returnValue=someMethod(tStamp);
    I've checked the value of tStamp inside method and its getting populating but after the method call value of tStamp stays null.
    Please let me know what I'm doing wrong.
    Thanks

    sam2020 wrote:
    In other words if a Object is instantiated then its value would be retained after it is changed in the method. Err...kind of. A reference is something that can be pointed to any object of an agreeable type, and has little to do with any particular object. For instance, you could do this
    Object ts = new Object();
    ts = new Object();
    ts = new Object();
    ts = new Object();
    ts = new Object();
    ts = new Object();
    ts = new Object();At this point, ts has pointed to 8 completely separate objects, but you've only used one reference. Each time you reassign ts to a different Object, all references to the previously referenced objects have been lost and the Object will eventually be garbage collected.
    Similarly you can create an Object without ever having assigned it to a reference:
    new Object();
    new Object();
    new Object();
    new Object();
    new Object();
    new Object();
    new Object();
    new Object();This time, you've created 8 objects and have never even used a reference.
    Think of a reference as a plate of food.
    When you take a plate out of the cupboard, it's not linked to any specific food, even if there is a bunch of food in your fridge. This is similar to:
    Object plate; //or Object plate = null;You could bake a cake, but this has nothing to do with your plate...yet.
    Object cakePan = new Object(); //bake a cake...but it's not on your plate yet!Then you can transfer the cake to your plate
    Object plate = cakePan; //now plate is holding your new cake...but that doesn't make your plate a cake!Of course you could always scrape the rest of the cake into the garbage:
    Object plate = null;Or put something else on it instead:
    Object plate = fridge.takePizza();But the point is, your plate isn't tied down to what's on it. Just like a reference isn't tied (or even very much related) to what it points to. (Unless you use the final keyword).
    Can you tell I'm hungry?
    Edit:
    To tie this into your original question, when you call a method, you could pass the reference (plate) by value or by reference.
    So if you wanted to give your brother the rest of your cake, you could either:
    a) Pass him the plate (pass by reference). This would allow him to replace the contents of the place before he gives it back to you. Or,
    b) Move the cake to his plate (pass by value). This means he can change the cake (eat some, whatever), but he can't change what's on YOUR plate.
    Java always uses b).
    This analogy of course breaks down when you realize that with references, multiple references can reference the same object, but you can't put a single piece of cake on multiple plates.
    Edited by: endasil on 16-May-2008 4:36 PM

  • I am having problems with java

    Hi
    I am using a banking website for online management. I use Safari. Java is required for this applet to run.
    When I login, the message comes Timeout! And the applet shut offs.
    I am attaching the message that comes when I want to login.
    Any solution?
    Regards
    Ruumi

    Hello,
    If Java worked before March then it's probably been disabled my those lovely people at Microsoft who are so helpful and really want Java to be an integral part of our lives.
    Your problem may have been caused by the silent removal of the MSJVM from your machine, which can disable the Sun JVM without warning.
    To test this theory, type "jview" into a command window (Start -> Run, "cmd")
    this will tell you if you still have the MSJVM (which is probably a "no")
    Then type "java -version". (which tells you the installed version of the Sun JVM)
    If the Sun JVM is installed and the MSJVM is not, then create an empty text file called msjava.txt, then rename it to msjava.dll and put it in the System32 folder of the windows directory (probably C:\WINDOWS\SYSTEM32)
    This will fool your computer into thinking the MSJVM is still installed. Then all the JVM calls will be passed to the Sun JVM and Java should work again.
    If this doesn't work, you may need to install a different major version of the Sun JVM from http://java.sun.com/products/archive/index.html.
    Hope this helps.
    Alastair.

  • Problem with Java 3D API help!

    hellow people,
    i'm working working on a 3D game project. My program compiles fine but when it runs it gives me the following error:
    Java 3D ERROR : wglGetExtensionsStringARB not support !
    - The specified procedure could not be found.
    Fallback to use standard ChoosePixelFormat.
    Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=1.1)
    Exception in thread "J3D-Renderer-1" java.lang.IllegalStateException: GL_VERSION
            at javax.media.j3d.Canvas3D.createNewContext(Native Method)
            at javax.media.j3d.Canvas3D.createNewContext(Canvas3D.java:2429)
            at javax.media.j3d.Renderer.doWork(Renderer.java:747)
            at javax.media.j3d.J3dThread.run(J3dThread.java:250)I tried installing the latest version of openGL , but it still gives the same error.
    I'm using GeForce4 MX Intergrated Graphics card on windows pro.

    This should be posted in the Java 3D forum. I had the same problem. I had to install directX to fix it. :(

  • More problems with java query API - getExcerpt fails

    If I write my code this way, everything works:
    mySearchRequest.setQuery(new oracle.ultrasearch.query.Contains(searchString, metadata));
    But if I do this, Document.getExcerpt() starts returning null for the same search hits:
    mySearchRequest.setQuery(
    new oracle.ultrasearch.query.And(
    new oracle.ultrasearch.query.Contains(searchString, metadata),
    new oracle.ultrasearch.query.From(metadata.getGroup(groupToSearch))
    Does anybody know how to make this work? I need to limit my searches by groups so that I don't have to create a new UltraSearch Instance for every single web site that has to be crawled (I have several).
    Troy

    Well, I finally discovered he solution on my own, by reverse-engineering Oracle's own search.jsp (which does not use Oracle's custom tag library, btw) (probably because same doesn't really work, or at least it doesn't what's in the documentation doesn't work) (which isn't surprising).
    You have to do the "From" part of the query as an "attribute filter".
    oracle.ultrasearch.query.Query searchQuery=
    new oracle.ultrasearch.query.Contains(searchString, metadata);
    oracle.ultrasearch.query.Query attrQuery=
    new oracle.ultrasearch.query.From(metadata.getGroup(groupToSearch));
    oracle.ultrasearch.query.Request searchRequest=new oracle.ultrasearch.query.Request();
    searchRequest.setQuery(searchQuery);
    searchRequest.setFilter (attrQuery);
    Maybe that will do somebody some good somewhere...
    Troy

  • Still having problem with java regex

    Hi
    I have the following data in a text file:
    InstallDate:
    Location:
    Name: ps1
    PortName: IP_192.45.10.200
    ServerName:
    ShareName:
    I want to print out the string after the word "Name: " in this case it would be "ps1"
    I ve tried it as follow but it does not seem to work:
    Pattern p =Pattern.compile("Name :(\\w*)");
    String line = null;
    try
    BufferedReader in = new BufferedReader(new FileReader("c:\\printerinfo.txt"));
    while((line = in.readLine()) != null)
    Matcher m = p.matcher(line);
    boolean matchFound = m.find();
    if(matchFound )
    String printName = m.group(1);
    System.out.println( printName );
    else
    System.out.println("line" + line);
    catch (Exception e)
    System.out.println(e);
    Does anyone have a suggestion on how I can get this to work?
    thanks

    Your line has a type: Pattern p =Pattern.compile("Name: (\\w*)");The space should be after ":", not before it.
    This should pick up both Name: ps1 and PortName: something, since you Matcher.find() will find anthing that matches.
    To match only from the beginning of the line, use:Pattern p =Pattern.compile("^Name: (\\w*)");

Maybe you are looking for

  • Sql server 2000 driver problem!!! Help

    sql server driver problem hi...i want to install sql server 2000 into my IDE Jbuilder 8 Enterprise Edition i have follow the instruction that i make a config file by using enterprise setup tool, database driver in Jbuilder and location select <Jbuild

  • PO shipping error

    Hi, I am not able to view the shipping tab in PO while creating a Inter company stock transfer order. Can U guys let me know what r the possible reasons behind the shipping tab not appearing in PO. thanks in advance

  • Webdynpro Tabstrip display

    Hi, I am facing an issue with ABAP WD Tabstrip display and wanted guidance. Issue: I have two tabs, each tab has a transparent container which in turn contains a view container respectively. An ALV is embedded in each of these view container in the W

  • Error opening video files - mp4 h.264 - Error -50: an unknown error

    Whenever I try and load a movie in Quicktime then I get the message: "Error -50: an unknown error occurred" and then it fails to load. Quicktime appears to be left running in the background, but there is no GUI. The player can be launched without a f

  • Delta Infopackage

    Dear Experts, Could you please tell me the difference between init and delta infopackage. shall there be two infopackage ie one for init and one for delta. What i understood is initil when we run the init .then the next time we will get delta infopac