jstack not working on server - java

We use jstack on servers to detect if java apps are getting deadlocked. It's not working on one of our Linux servers. I think O/S version is:
$cat /etc/issue.net
Red Hat Enterprise Linux Server release 5.6 (Tikanga)
Kernel \r on an \m
Java version running on server:
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
When I try:
jstack 19114
I get:
19114: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
When I try:
jstack -F 19114
I get:
Attaching to process ID 19114, please wait...
Debugger attached successfully.
Deadlock Detection:
No deadlocks found.
Thread 19180: (state = BLOCKED)
Error occurred during stack walking:
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.execute(LinuxDebuggerLocal.java:152)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet(LinuxDebuggerLocal.java:466)
at sun.jvm.hotspot.debugger.linux.LinuxThread.getContext(LinuxThread.java:65)
at sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess.getCurrentFrameGuess(LinuxAMD64JavaThreadPDAccess.java:92)
at sun.jvm.hotspot.runtime.JavaThread.getCurrentFrameGuess(JavaThread.java:256)
at sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThread.java:218)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:76)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.tools.jstack.JStack.runJStackTool(JStack.java:118)
at sun.tools.jstack.JStack.main(JStack.java:84)
Caused by: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet0(Native Method)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.access$800(LinuxDebuggerLocal.java:51)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1GetThreadIntegerRegisterSetTask.doit(LinuxDebuggerLocal.java:460)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.run(LinuxDebuggerLocal.java:127)
Anyone know what is causing this?

It is required to run jstack as the same user that started the java process. This resolves the above stacktrace error. See this posting: jstack thread dump error: get_thread_regs failed for a lwp for more detail. As soon as I sudoed the jstack command, the error disappeared.

The syntax is simply:
sudo -u USERID jstack PID
Example:
sudo -u tomcat7 jstack 2498

Try using kill -3 <pid> instead to get the stacktrace of your VM.

Can use a jsp that gives you similar output instead.
Following jsp prints the thread stack info to screen but you could change the output to a file as well or use in a regular POJO class.
<%# page import="java.util.*" %><%
Map<Thread,StackTraceElement[]> map = Thread.getAllStackTraces();
Set tt = map.keySet();
Iterator<Thread> ti = tt.iterator();
Thread thrd = null;
final String br = "<" + "br" + ">";//website does not parse it
try{
int cnt = 1;
StackTraceElement[] st = null;
while(ti.hasNext() ){
thrd = ti.next();
out.print(br + "<" + "hr" + ">" + br + cnt + " \"" + thrd.getName());
out.println("\", priority :" + thrd.getPriority() + ", state :" + thrd.getState());
out.print(", id :" + thrd.getId() + ", hex :" + Long.toHexString(thrd.getId()) );
out.print(" alive :" + thrd.isAlive() + ", daemon :" + thrd.isDaemon() );
out.print(" interrupted :" + thrd.isInterrupted() + ", daemon :" + thrd.isDaemon() );
out.print(".\n" + br);
st = thrd.getStackTrace();
for(int sti = 0; sti < st.length; sti++){
out.println(br + " " + st[sti].getClassName() + "." + st[sti].getMethodName());
out.println("(" + st[sti].getFileName());
if(st[sti].getLineNumber() < 1){
out.print("Native method");
}else{
out.print(":" + st[sti].getLineNumber());
}
out.println(")");
}
out.println("");
cnt++;
}
}catch(Exception e){
out.println(br + "err " + e + br);
}
%>
Sample output:
121 "Thread-40", priority :6, state :WAITING , id :134, hex :86 alive :true, daemon :false interrupted :false, daemon :false.
java.lang.Object.wait (Object.java Native method)
java.lang.Object.wait (Object.java :485)
org.jpos.iso.ISOMUX$Receiver.run (ISOMUX.java :326)
java.lang.Thread.run (Thread.java :662)
122 "Thread-48", priority :5, state :TIMED_WAITING , id :142, hex :8e alive :true, daemon :false interrupted :false, daemon :false.
java.lang.Thread.sleep (Thread.java Native method)
org.jpos.apps.qsp.QSP.monitorConfigFile (QSP.java :301)
org.jpos.apps.qsp.QSP.run (QSP.java :346)
java.lang.Thread.run (Thread.java :662)

Related

Implement Multi-threading on Java Program

I'm writing a little Java program which uses PsExec.exe from cmd launched using ProcessBuilder to copy and install an application on networked PC (the number of PC that will need to be installed can vary from 5 to 50).
The program works fine if I launched ProcessBuilder for each PC sequentially.
However to speed things up I would like to implement some form of MultiThreading which could allow me to install 5 PC's at the time concurrently (one "batch" of 5 X Processbuilder processes untill all PC's have been installed).
I was thinking of using a Fixed Thread Pool in combination with a Callable interface (each execution of PsExec returns a value which indicates if the execution was succesfull and which I have to evaluate).
The code used for the ProcessBuilder is:
// Start iterating over all PC in the list:
for(String pc : pcList)
{
counter++;
logger.info("Starting the installation of remote pc: " + pc);
updateMessage("Starting the installation of remote pc: " + pc);
int exitVal = 99;
logger.debug("Exit Value set to 99");
try
{
ProcessBuilder pB = new ProcessBuilder();
pB.command("cmd", "/c",
"\""+psExecPath+"\"" + " \\\\" + pc + userName + userPassword + " -c" + " -f" + " -h" + " -n 60 " +
"\""+forumViewerPath+"\"" + " -q "+ forumAddress + remotePath + "-overwrite");
logger.debug(pB.command().toString());
pB.redirectError();
Process p = pB.start();
InputStream stErr = p.getErrorStream();
InputStreamReader esr = new InputStreamReader(stErr);
BufferedReader bre = new BufferedReader(esr);
String line = null;
line = bre.readLine();
while (line != null)
{
if(!line.equals(""))
logger.info(line);
line = bre.readLine();
}
exitVal = p.waitFor();
} catch (IOException ex)
{
logger.info("Exception occurred during installation of PC: \n"+pc+"\n "+ ex);
notInstalledPc.add(pc);
}
if(exitVal != 0)
{
notInstalledPc.add(pc);
ret = exitVal;
updateMessage("");
updateMessage("The remote pc: " + pc + " was not installed");
logger.info("The remote pc: " + pc + " was not installed. The error message returned was: \n"+getError(exitVal) + "\nProcess exit code was: " + exitVal);
}
else
{
updateMessage("");
updateMessage("The remote pc: " + pc + " was succesfully installed");
logger.info("The remote pc: " + pc + " was succesfully installed");
}
Now I've read some info on how to implement Callable and I would like to enclose my ProcessBuilder in a Callable interface and then submit all the Tasks for running in the for loop.
Am I on the right track?
You can surely do that. I suppose you want to use Callable instead of runnable to get the result of your exitVal ?
It doesn't seem like you have any shared data between your threads, so I think you should be fine. Since you even know how many Callables you are going to make you could create a collection of your Callables and then do
List<Future<SomeType>> results = pool.invokeAll(collection)
This would allow for easier handling of your result. Probably the most important thing you need to figure out when deciding on whether or not to use a threadpool is what to do if your program terminates while threads are still running; Do you HAVE to finish what you're doing in the threads, do you need to have seamless handling of errors etc.
Check out java threadpools doc: https://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
or search the web, there are tons of posts/blogs about when or not to use threadpools.
But seems like you're on the right track!
Thank you for your reply! It definitely put me on the right track. I ended up implementing it like this:
ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(5); //NEW
List<Future<List<String>>> resultList = new ArrayList<>();
updateMessage("Starting the installation of all remote pc entered...");
// Start iterating over all PC in the list:
for(String pc : pcList)
{
counter++;
logger.debug("Starting the installation of remote pc: " + pc);
psExe p = new psExe(pc);
Future<List<String>> result = executor.submit(p);//NEW
resultList.add(result);
}
for(Future<List<String>> future : resultList)
{.......
in the last for loop I read the result of my operations and write them on screen or act according to the result returned.
I still have a couple of questions as it is not really clear to me:
1 - If I have 20 PC and submit all the callable threads to the pool in my first For loop, do I get it correctly that only 5 threads will be started (threadpool size = 5) but all will already be created and put in Wait status, and only as soon as the first running Thread is complete and returns a result value the next one will automatically start until all PC are finished?
2 - What is the difference (advantage) of using invokeall() as you suggested compared to the method I used (submit() inside the for loop)?
Thank you once more for your help...I really Love this Java stuff!! ;-)

Appium Server, on windows, is throwing error: Responding to client that we did not find a valid resource

I am trying to run Appium Serve on my Windows 7 machine using a simple command:
D:\Appium\node.exe D:\Appium\node_modules\appium\bin\Appium.js -g C:\Users\vdopia\AppData\Local\Temp\applog_12232015_110310.txt --no-reset
in command prompt, it shows that Appium is started. When I browse the url http://127.0.0.1:4723, I get the message below in my command prompt and because of this I am not able initialize remotedriver also. Surprisingly, the same thing works well in MAC.
Logs:
> info: --> GET / {}
> info: [debug] Responding to client that we did not find a valid resource
> info: <-- GET / 404 0.712 ms - 47
> info: <-- GET /favicon.ico 200 0.535 ms - 1150
I am pasting code here to start appium server, first I am writing command in a sh or bat file then executing the bat file.
public static boolean startAppiumServer()
{
//Kill any Existing Appium Before Starting new session
logger.info("Stopping any running instance of appium. ");
try{SDKCommonUtils.killAppiumServer();}catch(Exception e){}
boolean flag = false;
File logFile = null;
String commandFile = null;
if(System.getProperty("os.name").matches("^Windows.*"))
{
//Getting temp dir
String tempDir = System.getProperty("java.io.tmpdir").toString();
logFile = new File(tempDir+"\\applog"+"_"+MobileTestClass_Methods.DateTimeStamp()+".txt");
commandFile = System.getenv("AUTOMATION_HOME").concat("\\tpt\\appium_commands.bat");
String appiumCmdLocation_Windows = MobileTestClass_Methods.propertyConfigFile.getProperty("appiumCmdLocationForWindows").toString();
String nodeExe = appiumCmdLocation_Windows.concat("\\node.exe");
String appiumJs = appiumCmdLocation_Windows.concat("\\node_modules\\appium\\bin\\Appium.js");
String strText = "start /B " + nodeExe + " " + appiumJs + " -g " + logFile.toString() + " --full-reset --command-timeout 60 ";
FileLib.WriteTextInFile(commandFile, strText);
}
else
{
logFile = new File("/tmp/applog"+"_"+MobileTestClass_Methods.DateTimeStamp()+".txt");
commandFile = System.getenv("AUTOMATION_HOME").concat("/tpt/appium_commands.sh");
String strText = "export PATH=$PATH:/usr/local/bin; /usr/local/bin/appium -g " + logFile.toString() + " --full-reset --command-timeout 60 " ;
FileLib.WriteTextInFile(commandFile, strText);
}
try
{
logger.info("Executing Command File: "+ commandFile +" to start appium service. ");
Runtime.getRuntime().exec(commandFile);
/** wait until appium server is started */
flag = waitForAppiumServer();
}
catch(Exception e)
{
flag = false;
logger.error("There were some issues while executing command to launch appium service. ",e);
}
return flag;
}
If you do not provide server address then it will be used as 0.0.0.0 from command prompt in windows as
info: Appium REST http interface listener started on 0.0.0.0:4723.
Please provide --address 127.0.0.1 --port 4723 parameter from command line and try to use same address and port while initializing driver object in your script.

Java Runtime.exec("sleep 180 ; ...")

I tried to ban an ip-adress temporarly if someone tryes to not join over the proxy to the minecraft server.
String st = e.getRealAddress() + "";
if(!st.startsWith("/x.x.x.x")) {
Runtime runtime = Runtime.getRuntime();
runtime.exec("iptables -A INPUT -s " + st.replace("/","") + " -j DROP");
runtime.exec("sleep 180 ; iptables -D INPUT -s " + st.replace("/","") + " -j DROP");
}
But for some reason to only executes the -A command and after I've waited three minutes I wasn't able to connect. What did I have done wrong?
you can:
decompose yourself the orders in java: iptables , wait, sleep, iptables, ...
then you must wait first iptables to finish:
use waitFor :
Process p = Runtime.getRuntime().exec("your command iptables");
p.waitFor();

Start Minecraft On Mac With Java

I am trying to make a java program that will launch minecraft in offline mode with whatever username i want so i can have usernames like Notch and deadmau5 and i am using this code to launch it on mac and windows (Currently Testing on mac):
public void startMacMinecraft(String username) throws IOException,
InterruptedException {
System.out.println(defaultDirectory());
String sysUser = System.getProperty("user.name");
String commandString = "java -cp "
+ defaultDirectory()
+ "/minecraft/bin/minecraft.jar:"
+ defaultDirectory()
+ "/minecraft/bin/lwjgl.jar:"
+ defaultDirectory()
+ "/minecraft/bin/lwjgl_util.jar:"
+ defaultDirectory()
+ "/minecraft/bin/jinput.jar: -Djava.library.path="
+ defaultDirectory()
+ "/minecraft/bin/natives -Xmx1024M -Xms512M net.minecraft.client.Minecraft '"
+ username + "'";
CommandLine command = CommandLine.parse(commandString);
DefaultExecutor executor = new DefaultExecutor();
int exitValue = executor.execute(command);
System.out.println(exitValue);
System.out.println("\nTry Two:\n");
String javaExe = System.getProperty("java.home") + "/bin/java";
}
public void startWinMinecraft(String username) throws IOException,
InterruptedException {
String sysUser = System.getProperty("user.name");
String commandString = "Java -Xms512m -Xmx1024m -cp \"%APPDATA%\\.minecraft\\bin\\*\" -Djava.library.path=\"%APPDATA%\\.minecraft\\bin\\natives net.minecraft.client.Minecraft \""
+ username + "\"";
CommandLine command = CommandLine.parse(commandString);
DefaultExecutor executor = new DefaultExecutor();
int exitValue = executor.execute(command);
System.out.println(exitValue);
}
private static String defaultDirectory() {
String OS = System.getProperty("os.name").toUpperCase();
if (OS.contains("WIN"))
return System.getenv("APPDATA");
else if (OS.contains("MAC"))
return System.getProperty("user.home") + "/Library/Application "
+ "Support";
else if (OS.contains("NUX"))
return System.getProperty("user.home");
return System.getProperty("user.dir");
}
Which i am trying to adapt from this applescript which i have run before and got from https://gaming.stackexchange.com/questions/46608/how-can-i-run-minecraft-in-offline-mode-on-os-x-and-still-have-my-name that i will paste right here:
property user_name : "Player"
display dialog "Enter A User Name" default answer "" buttons {"Cancel", "Continue"} default button 2
set the user_name to text returned of the result
set UsrApp to (path to current user folder)
set UsrApp_unx to POSIX path of UsrApp
set MineScript to "java -cp " & UsrApp_unx & "Library/Application\\ Support/minecraft/bin/minecraft.jar:" & UsrApp_unx & "Library/Application\\ Support/minecraft/bin/lwjgl.jar:" & UsrApp_unx & "Library/Application\\ Support/minecraft/bin/lwjgl_util.jar:" & UsrApp_unx & "Library/Application\\ Support/minecraft/bin/jinput.jar: -Djava.library.path=" & UsrApp_unx & "Library/Application\\ Support/minecraft/bin/natives -Xmx1024M -Xms512M net.minecraft.client.Minecraft '" & user_name & "'"
do shell script MineScript
When i run the applescript it works perfectly fine but when i run my adapted version it gives me a class not found error:
Logging in as: Player
/Users/Connor/Library/Application Support
Exception in thread "main" java.lang.NoClassDefFoundError: Support/minecraft/bin/minecraft/jar:/Users/Connor/Library/Application
Caused by: java.lang.ClassNotFoundException: Support.minecraft.bin.minecraft.jar:.Users.Connor.Library.Application
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
at info.connorbp.GUIApp.LoginPanel.startMacMinecraft(LoginPanel.java:137)
at info.connorbp.GUIApp.LoginPanel$1.actionPerformed(LoginPanel.java:82)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6375)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6140)
at java.awt.Container.processEvent(Container.java:2083)
at java.awt.Component.dispatchEventImpl(Component.java:4737)
at java.awt.Container.dispatchEventImpl(Container.java:2141)
at java.awt.Component.dispatchEvent(Component.java:4565)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4619)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4280)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4210)
at java.awt.Container.dispatchEventImpl(Container.java:2127)
at java.awt.Window.dispatchEventImpl(Window.java:2482)
at java.awt.Component.dispatchEvent(Component.java:4565)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:684)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:643)
at java.awt.EventQueue$1.run(EventQueue.java:641)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:657)
at java.awt.EventQueue$2.run(EventQueue.java:655)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:654)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
does anyone know what i am doing wrong or how to fix it?
EDIT:
Even stranger yet, I went into the events area of the applescript area and found the exact command the applescript was running:
java -cp /Users/Connor/Library/Application\\ Support/minecraft/bin/minecraft.jar:/Users/Connor/Library/Application\\ Support/minecraft/bin/lwjgl.jar:/Users/Connor/Library/Application\\ Support/minecraft/bin/lwjgl_util.jar:/Users/Connor/Library/Application\\ Support/minecraft/bin/jinput.jar: -Djava.library.path=/Users/Connor/Library/Application\\ Support/minecraft/bin/natives -Xmx1024M -Xms512M net.minecraft.client.Minecraft 'username'
and even when a tried running the script that came directly from the applescript i got another java.lang.NoClassDefFoundError error, even though i took the command directly from the applescript that is working.
In the default launcher, whatever username you provide gets used for offline mode, so writing a separate launcher is pointless.
In any case, decompiling the launcher should give us a pretty good idea of how to launch the game.
There is a lot of code so I recommend decompiling it yourself. For mac, JD-GUI does an alright job. For windows, I can't recommend a decompiler, but thats what google is for :)
After you get the launcher source code, have a peek at public void login(String userName, String password) in net.minecraft.LauncherFrame. Also relevant is net.minecraft.Launcher.
Reading through that should give you a pretty good idea of how to launch minecraft.
Oops, forgot about this question. I was actually just missing some of the code that was needed in order to launch minecraft.

Why do the outputs differ when I run this code using NetBeans 6.8 and Eclipse? [duplicate]

This question already has an answer here:
Closed 12 years ago.
Possible Duplicate:
Why do the outputs differ when I run this code using NetBeans 6.8 and Eclipse?
When I am running the following code 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 it in NetBeans, it does not seem to find any ports ..
public static void test() {
Enumeration lists=CommPortIdentifier.getPortIdentifiers();
System.out.println(lists.hasMoreElements());
while (lists.hasMoreElements()) {
CommPortIdentifier cn =
(CommPortIdentifier)lists.nextElement();
if ((CommPortIdentifier.PORT_SERIAL==cn.getPortType())) {
System.out.println(
"Name is serail portzzzz " +
cn.getName()+
" Owned status " +
cn.isCurrentlyOwned());
try {
SerialPort port1=(SerialPort)cn.open("ComControl",800000);
port1.setSerialPortParams(
9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
System.out.println("Before get stream");
OutputStream out=port1.getOutputStream();
InputStream input=port1.getInputStream();
System.out.println("Before write");
out.write("AT".getBytes());
System.out.println("After write");
int sample=0;
//while((( sample=input.read())!=-1)){
System.out.println("Before read");
//System.out.println(input.read() + "TEsting ");
//}
System.out.println("After read");
System.out.println(
"Receive timeout is " +
port1.getReceiveTimeout());
}
catch(Exception e) {
System.err.println(e.getMessage());
}
}
else {
System.out.println(
"Name is parallel portzzzz " +
cn.getName() +
" Owned status " +
cn.isCurrentlyOwned() +
cn.getPortType() +
" ");
}
}
}
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
An initial guess would be that the library you use use native code enclosed in a DLL and that code cannot be found giving an error earlier you have missed, and the code falls back to a dummy behaviour.
I would have a closer look at the initialization code to see what happens there.

Categories