I've been attempting to execute a java application using SSH from a remote machine
but it quite doesn't work well :(
To execute this application on the local machine,
I wrote a shell script including java command, and it works okay on local.
So, I tried to execute this shell script remotely via ssh like below
ssh username#hostname execute.sh
It seemed to worked out at first, but then result in the following error, and shutdown.
GC Warning: Repeated allocation of very large block (appr. size 929792): May lead to memory leak and poor performance.
GC Warning: Out of Memory! Returning NIL!
I understood what the message means reading this page ( http://www.hpl.hp.com/personal/Hans_Boehm/gc/debugging.html ),
yet, I have no idea how come this error occur only when I execute java command remotely.
Does anyone know anything about this?
Or, is there any better way to execute java command remotely
other than ssh?
Any idea or information will be greatly appreciated!
Regards,
May
java version: Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
The only difference between exec'ing a command locally vs remotely would be the environmental variable setup. Please check that environment variables your program might be using (such as JAVA_HOME) are being set to expected values
It worked out using "expect" command. Still I don't know the reason of the GC Warnings thou..
Thank you guys for all the comments.
Related
I work on a Macbook and I would like to close some running applications such as Remote Desktops through using Java.
I'm quite new to programming in Java and other than Google and StackOverflow I'm not sure where to go. I already looked for a solution on Google but all I can find are instruction on how to close Java on Mac OS, not actually how you close a running application through Java code.
So I am looking for some pointers on what Java commands I should use to close a running application in Mac OS. Thank you very much :)
While programming in Java, you only have access to do things inside the JVM. But your code inside the JVM wouldn't usually have permissions to affect other processes running on the operating system.
You can definitely call an external command with something like this:
Process process = Runtime.getRuntime().exec("kill 12345");
That would run the kill command on process id 12345. This would work, assuming you have the right permissions.
You can get more information on the exec command in the docs: https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String)
We are porting OpenJDK to RISC-V. We're at the point that the interpreter builds. We need to debug it, using GDB. However, we haven't been able to find a working GDB that works with RISC-V QEMU. Any help would be much appreciated.
It depends on what you mean by "GDB that works with QEMU". There's three use cases here
Running system-mode QEMU, trying to debug a machine-mode or supervisor-mode program (like the Linux kernel, for example). For this, you should be able to use the upstream RISC-V GDB port attached to QEMU's built-in GDB stup to debug like normal.
Running user-mode QEMU, trying to debug a user-mode program. I've never done this before, but I think you can still use QEMU's built-in GDB stub and connect with the upstream GDB.
Running system-mode QEMU, trying to debug a user-mode program (like OpenJDK, for example). In this case QEMU doesn't actually factor in to the equation, as you're really just looking for a standard Linux GDB port. Both our Linux and GDB ports are currently buggy when it comes to native debugging, but you should be able to take the latest upstream versions of both and at least get some work done. There's lots of issues with drivers in our upstream Linux port, but if you're just using QEMU's virt machine then you should be good to go.
I'm not actually sure StackOverflow is the best place to ask this question, as the answer will be obsolete pretty much as soon as it's been asked.
I want to run a java program on Cygwin. The code takes two very large files as an input. When I attempted to run the program on Cygwin, I got the following messege:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at code_name.main(code_name.java:52)
I tried to increase the heapsize (java -Xms1024m -Xmx2048m javafile inputfile1 inputfile2) but still it didn't work!
Does it solve the problem to run the code on a remote server with bigger memory? and if yes, how to define a server directory on Cygwin?
Note that I'm using Windows, and my machine is 64-bit
First of all, it is not Java's fault that the application is using too much memory. And it isn't Cygwin's fault either.
Most likely, it is one of the following:
The application is using memory inefficiently; e.g. loading the files into memory in their entirety.
The application has a memory leak
The problem is inherently too big to solve with a 2GB heap.
Does it solve the problem to run the code on a remote server with bigger memory?
Possibly yes, possibly no. It depends on the reason that the application ran out of memory, and on the problem size. It also depends on how much bigger the server is.
Hint: you should work out why the application is running out of memory with a 2GB heap. There will be some clues in the application's source code, and in the stacktrace.
And if yes, how to define a server directory on Cygwin?
I don't know what you mean by that.
I would suggest that you just login to the remote server, install cygwin, Java and the other tools that you need, and run the application from the remote server's command prompt.
Environment:
Headless Linux server
Red Hat Enterprise Linux Server release 6.7 (Santiago)
2.6.32-573.12.1.e16.x86_64
I have a java(7) program that I run from command line that spawns multiple threads and hits a oracle database simultaneously using ojdbc7.
Intermittently I see connection reset error:
Could not get JDBC Connection; nested exception is java.sql.SQLRecoverableException: IO Error: Connection reset
exactly as reported here and resolved here.
I tried the following to mitigate the issue:
Add these variations to my command line
-Djava.security.egd=file:///dev/urandom
-Djava.security.egd=file:/dev/../dev/urandom
-Djava.security.egd=file:/dev/./urandom
Tried adding to java.security file
securerandom.source=file:///dev/urandom
securerandom.source=file:/dev/../dev/urandom
securerandom.source=file:/dev/./urandom
Also tried ojdbc6
But I still see the issue. Which means that even with urandom in use, still there is not enough realtime entropy. Which is understandable, because when I run my java program, everything else is stopped (this is a application server with multiple running jvms, usually. )
I am wondering if there is anything I can do to 'cause' entropy on the server. I have limited access to this server so I am limited in what I can do. This java job is expected to run for a couple of hours, so I can not keep typing on the keyboard etc. May be run a simple program in the background that 'does' something?
Any ideas? I tried rngd command but apparently I do not have permission to use it. Any help greatly appreciated, been stuck with this issue for a while now.
Edit:
I tried to run another java program (using java.awt.Robot) that simulates Keyboard presses continuously during my original program run, but due to limited permissions on the server I wasn't able to get it working. But in general, would that be a good way to ensure some entropy?
I have a java process running on a Linux box, but it cannot be started/re-started in debug mode. I read about the jsadebugd command and started the daemon, but I want to connect to it from an IDE(possibly Eclipse) debugger or maybe YourKit or jconsole. How can I do this? The remote JVM is 1.6+.
I assume since you mentioned Yourkit and other tool that what you really want to do is look at object state inside your applications. There are a couple of options, though I don't think it gets you the ability to set break-points like Eclipse or another debugger would (though I'd be intersted in hearing what restricts you from starting the process in debug mode - technical? process?)
have you tried connecting with: VisualVM? I don't believe you need to start in debug mode, and it will give you the ability to navigate the object graph, and inspect objects. You can even use it to take heapdumps and do some ad-hoc analysis through them using OQL queries.
If you're running on JDK6+ - have you tried instrumenting with btrace? Some notes from the sailfin team sounded promising, and like DTrace in Solaris, this seem like it would be useful in a variety of situations.
I am not sure if I understand your restrictions correctly but you can start JVM with debugging server (serving JDWP) enabled. See for example "Sun VM Invocation Options" in http://java.sun.com/j2se/1.4.2/docs/guide/jpda/conninv.html
Then you can connect your Eclipse debugger to running JVM. See "Remote debugging" section here http://www.ibm.com/developerworks/library/os-ecbug/
I'm not sure that this is exposed by Eclipse, but here's how to do it with jdb:
http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/tooldescr.html#gbmog