I am trying to debug an applet on Windows 8 using Java 1.7.0_21.
I have added the bleow to the runtime parameters.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
When I try to connect I get "Could not open connection to the host, on port 5005" error on both local and remote machines.
If I do a netstat -an I don't see any port 5005 listening. It seems the JVM is not opening the listening debug port.
I have added the port to the firewall and even completely disabled the firewall, but no difference.
Has anyone else here tried to debug Java 7 on Windows 8?
Thanks
I'm having the same problem and can a little light on the issue. I don't have a solution yet, which is why I came here, but this may help find the answer.
The problem is in the actual run-time being launched by the JRE. If you look at the executable in the Java control panel, it will be javaw.exe. So you're adding the debug flags to that. If you use Process Explorer to look at the actual process that's running your applet, it's java.exe. I don't know if javaw.exe is just spawning java.exe then dying or what, but the flags are never getting passed onto java.exe.
If you go to the Java tab in the control panel, you used to be able to add another run-time there. Well, you still can, but after clicking OK then Apply on the next dialog tab, then clicking back into the Java tab, your added run-time will be gone. None of the settings that I've modified have made the browser plugin get the run-time parameters passed on, which makes it impossible to debug the applet in the browser context.
Did it ... almost !
Since I'm stuck I did it the hard way : replaced java exe by one of my own which forced java into debug mode
(please be gentle this is not high quality dev :) )
exeFile
to point to your java dirstdoutRedirect
and stderrRedirect
too-static-libgcc -static-libstdc++
for mingWfakeJava.exe
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<time.h>
#include<strings.h>
int main(int givenArgc,char *givenArgv[])
{
std::cout<<"step 0.a\n";
char exeFile[] = "c:\\java\\jdk1.7.0_21\\bin\\java.exe";
int prependArgc = 4;
char* prependArgv[] = {
"-Djava.compiler=NONE",
"-Xnoagent",
"-Xdebug",
"-Xrunjdwp:transport=dt_socket,address=2502,server=y,suspend=y"
};
std::cout<<"step 0.b\n";
time_t rawtime;
struct tm * timeinfo;
char date [80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (date,80,"%Y%m%d%H%M%S",timeinfo);
std::cout<<"step 0.c\n";
char stderrRedirect[100];
char stdoutRedirect[100];
sprintf(stderrRedirect,"2>d:\\tmp\\%s-stderr.txt",date);
sprintf(stdoutRedirect,">d:\\tmp\\%s-stdout.txt",date);
std::cout<<"step 0.d\n";
int appendArgc = 2;
char* appendArgv[] = {
stderrRedirect,
stdoutRedirect
};
std::cout<<"step 0.e\n";
int argc = prependArgc+givenArgc-1+appendArgc;
char** argv = (char**)malloc(argc*sizeof(char*));
std::cout<<"step 1.a\n";
char** src = prependArgv;
int nbItems = prependArgc;
int j = 0;
for(int i=0;i<nbItems;i++){
argv[j++]=src[i];
}
std::cout<<"step 1.b\n";
src = givenArgv;
nbItems = givenArgc;
for(int i=1;i<nbItems;i++){
argv[j++]=src[i];
}
std::cout<<"step 1.c\n";
src = appendArgv;
nbItems = appendArgc;
for(int i=0;i<nbItems;i++){
argv[j++]=src[i];
}
std::cout<<"step 3\n";
char str[4096];
strcpy(str,exeFile);
std::cout<<"step 4\n";
for(int i =0;i<argc;i++){
strcat (str," ");
strcat (str,argv[i]);
}
std::cout<<"step 5\n";
std::cout<<"will run : ";
std::cout<<str;
std::cout<<"\nstep 6\n";
system(str);
free(argv);
return 0;
}
I set the environment variable JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8989" as it suggested in the bug and it did the trick for me (at least in the Chrome)
There is a lot of bugs filled in sun bugs database related to that, and it seems it only resolved in java-8 (b97) Here is the link to the sun-bug which describe exactly the same problem and here is the place you can download java-8 (b99 is the current build)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With