Finding hard and soft open file limits from within jvm in linux

Hi All,
I have a problem where I need to find out the hard and soft open file limits for the process in linux from within a java program. When I execute ulimit from the terminal it gives separate values for hard and soft open file limits.
From shell if I run the command then the output is given below:
$ ulimit -n
1024
$ ulimit -Hn
4096
The java program is given below:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
public class LinuxInteractor {
public static int executeCommand(String command, boolean waitForResponse, OutputHandler handler) {
int shellExitStatus = -1;
ProcessBuilder pb = new ProcessBuilder("bash", "-c", command);
pb.redirectErrorStream(true);
try {
Process shell = pb.start();
if (waitForResponse) {
// To capture output from the shell
InputStream shellIn = shell.getInputStream();
// Wait for the shell to finish and get the return code
shellExitStatus = shell.waitFor();
convertStreamToStr(shellIn, handler);
shellIn.close();
catch (IOException e) {
System.out
.println("Error occured while executing Linux command. Error Description: "
+ e.getMessage());
catch (InterruptedException e) {
System.out
.println("Error occured while executing Linux command. Error Description: "
+ e.getMessage());
return shellExitStatus;
public static String convertStreamToStr(InputStream is, OutputHandler handler) throws IOException {
if (is != null) {
Writer writer = new StringWriter();
char[] buffer = new char[1024];
try {
Reader reader = new BufferedReader(new InputStreamReader(is,
"UTF-8"));
int n;
while ((n = reader.read(buffer)) != -1) {
String output = new String(buffer, 0, n);
writer.write(buffer, 0, n);
if(handler != null)
handler.execute(output);
} finally {
is.close();
return writer.toString();
} else {
return "";
public abstract static class OutputHandler {
public abstract void execute(String str);
public static void main(String[] args) {
OutputHandler handler = new OutputHandler() {
@Override
public void execute(String str) {
System.out.println(str);
System.out.print("ulimit -n : ");
LinuxInteractor.executeCommand("ulimit -n", true, handler);
System.out.print("ulimit -Hn : ");
LinuxInteractor.executeCommand("ulimit -Hn", true, handler);
If I run this program the output is given below:
$ java LinuxInteractor
ulimit -n : 4096
ulimit -Hn : 4096
I have used ubuntu 12.04, Groovy Version: 1.8.4 JVM: 1.6.0_29 for this execution.
Please help me in understanding this behavior and how do I get a correct result from withing the java program.

Moderator Action:
As mentioned in one of the earlier responses:
@OP this is not a Java question. I suggest you take it elsewhere, i.e. to a Unix or Linux forum.You posted this to a Java programming forum.
It is not a Java programming inquiry.
This off-topic thread is locked.
Additionally, you have answered your own question.
Don't bother posting it to one of the OS forums. It will get deleted as a duplicate cross-post.

Similar Messages

  • Can you perform "ymodem" and "kermit" data file transfers from within Labview ?

    If third party software vendors can do this, does anyone know who they may be ? In my application, the final product which I must communicate with is a finished commercial product which uses picodos as the operating system and accepts commands and transfers data over an RF Freewave modem, downloading and uploading files using both "ymodem" in procomm and "kermit"(old program) for large data files. I've got around most of the picodos stuff but I'm left with these two items which do not seem to be handled by National.
    Help !!!!
    Bryce Davis
    email: [email protected]
    902-426-3100 ext 284

    I have searched through our database and the web, and I cannot find any information about these modem protocols. I cannot even find a standard so that you could implement the code yourself. You might consider contacting our aliance members--it appears that some of them had modem toolkits in the past. The aliance list can be found at http://exchange.ni.com/servlet/Redirect?id=6361480
    Jeremy Braden
    National Instruments

  • Error. your computer must be running a supported version of Microsoft Visio and a browser that supports opening files directly from Visio Web Access.

    I have the following inside my SharePoint server 2013 :-
    EnterPrise Wiki site collection.
    i have both "Excel services Application "& "Visio Graphics Service" running correctly.
    The problem i am facing is as follow:-
    when a user click on an Excel sheet or Visio document , it will be shown inside the browser without any problem.
    but if the user click on "Open in Visio" OR "Open in Excel" links inside the browser, they will get the following errors:-
    Sorry, but to open this workbook, your computer must be running a supported version of Microsoft Excel and a browser that supports opening files directly from Office Web Apps.
    To open this document, your computer must be running a supported version of Microsoft Visio and a browser that supports opening files directly from Visio Web Access.
    I have the following settings inside my PC:-
    Office 2010 for Excel, word, power point,etc.
    Visio 2013.
    i have disabled SharePoint foundation support for office 2013
    Can anyone advice on this please?

    Hi,
    Please try to reset the Internet Explorer settings or open Internet Explorer in In-Private browsing and then check if this issue occurs.
    If the issue persists, please try to access SharePoint in another computer with Office 2013 and then check if this issue occurs. Or repair Office and restart your server.
    Here is a blog about the same issue for you to take a look at:
    http://sharepointexit.blogspot.com/2013/12/sorry-but-to-open-this-workbook.html
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Finding open file handles from core file using mdb/dbx

    Is it possible to find open file handles from a core file? The env is Solaris 5.10 SPARC.
    regards
    becks

    Interesting question, but it's more about Solaris OS/libraries than about Sun Studio C++ compiler. While there's a chance of getting it answered here, I also recommend to post the same question on one of the OpenSolaris forums:
    http://www.opensolaris.org/jive/index.jspa?categoryID=1
    For example, mdb forum:
    http://www.opensolaris.org/jive/forum.jspa?forumID=4

  • Can't open files directly from file server (MAVERICKS)

    since updating to Mavericks earlier today i have had the below problem
    I use a file server at work to access all my work files. i have no problem accessing the servers but when i try and when I double click to open a file (excel, word, pdf, etc) it says "the application cant be found"
    when Ihave the application open and i open the same file from within the application (file > open) it works fine. I just cannot open files directly from the file server by double clicking.
    in previous versions there have been no problems with this,
    any help would be great,

    Same issue here; I hadn't related it to upgrading to the latest OS 10.9.2. I've shutdown and restared multiple times. I've also rebuilt permissions on my hard drive as I thought it was the Finder but files on my local HD open file. Off the server, I cannot double-click or even drag to the dock. Files open fine if I open the app first then browse to find the file.

  • Finder beeps when I open files

    All of a sudden today, the Finder beeps when I open files from one of my external Firewire drives. Only one drive is affected. It doesn't matter what kind of document it is. The files seem to open okay, but the Finder beeps, as if there is a problem, when I open any of them. I've tried dismounting and re-mounting the drive, but it makes no difference. I've also tried re-starting the Finder, but that didn't change anything either.

    Could be Finder prefs.
    Navigate to ~(yourhome)/library/preferences and trash these two files:
    com.apple.finder.plist
    com.apple.sidebarlists.plist
    Then log out and back in again. Or restart.
    (You will have to reset a few finder prefs the way you like them.)
    Let us know.
    -mj
    [email protected]

  • I tried to rename a file, it gave me an error message (can't remember the number - 43??) and then the file disappeared from the original folder. When I do a search, the file comes up under the new name, but it does not show a path, and even though preview

    I tried to rename a file, it gave me an error message (can't remember the number - 43??) and then the file disappeared from the original folder. When I do a search, the file comes up under the new name, but it does not show a path, and even though preview shows the contents, I can't open the document (Powerpoint) and I can't move the document. I tried "Copy" and paste but it doesn't work. I tried "Share" with Airdrop and iChat, but the file is inaccessible. When i try to rename the file, it says the filename is too long.
    When I try to open it, it says the alias is not good, and asks if I want to fix the alias. I'm afraid to do that and lose all access to this document.
    Right now, it feels like a ghost document - it is on the computer intact, but it is in an undisclosed location and inaccessible.
    Please help!!

    I was able to resolve this by repairing permissions, even though no permissions error was listed specifically for that file.
    I could also have recovered it through Time Machine, but I'm interested in knowing how not to have this happen again!
    I was afraid of rebooting and possibly losing track even of the ghost.
    I did not try EasyFind - I'll keep that in mind next time.
    Thanks for all the comments.

  • Illustrator CC 2014 can't open files sent from Draw.

    Illustrator CC 2014 v18.0.0 (just installed today, 11/6/2014): I can't open files sent from Adobe Draw. The files send from Draw OK, but in Illustrator—which finally opens as advertised—I get an error message, i.e. The file "Dog - Drawing 1.draw" is in an unknown format and cannot be opened. This goes for all of my work, whether created in Ideas then opened recently in Draw, or files created in Draw from scratch.

    Illustrator files (.ai or .pdf)  that I save using CC 2014 vs 8.1.0 on my Windows (8.1) machine on our network server. I try to open them on Mac.
    'The File "x.pdf" is an unknown format and cannot be opened'
    This may in some way be related to accessing the file over the server since when I transfer the file to my lcal drive I don't get the same error.  I still can't open the file but I get an error near the end of the opening process :
    "Could not read the file because the plug-in made an invalid request of the Photoshop adaptor"
    Again, I can open this file using CC 2014 vs 8.1.0 on my Windows (8.1) machine.

  • Photoshop does not open files sent from LR

    Photoshop CS6 Extended does not open files sent from Lightroom. 4.4 on Win 7. What is wrong? PS starts but instead in LR the error "Could not open Photoshop appears.

    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    A screen shot of your settings or of the image could be very helpful too,
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • I uploaded and edited my RAW image, clicked 'Save As', and changed the file type from .psed to .jpg.

    I edited my raw image in Photoshop CS6, selected 'Save As', and changed the file type from .psed to .jpg. I also selected 12 and large file when the window popped up, concluding my 'saving as'. My computer does not recognize the file type and won't open them. Can someone help me? Thanks!

    When naming files, stick to the letters of the ENGLISH alphabet, numbers and underscores.  Do not use illegal characters like apostrophes, commas, asterisks, ampersands, hatch or pound signs, diacritics or accented characters, slashes, etc.
    While the period (dot) is not an illegal character per se, your file names should have only one period and that should always be followed by the file type extension.
    EDITED typo: se
    Message was edited by: station_two

  • PS CS6 on the mac pro: the bruch in hard and soft is the circle of the bruch bigger than then the effect. How can i bring it to normale?       /Users/jorisneyt/Desktop/Schermafbeelding 2014-11-07 om 10.04.59.png

    PS CS6 on the mac pro: the bruch in hard and soft is the circle of the bruch bigger than then the effect. How can i bring it to normale?

    Go to System Preferences>Accessibility>Display and the set the Cursor Size to Normal

  • Where can I find Installer and uninstaller log files in JSE 6?

    Where can I find Installer and uninstaller log files in JSE 6?

    For the installer log file, search for Sun_Java_Studio_Enterprise_6_2004Q1_install, or some portion of that.
    To find Java ES component product log files, search on Sun_ONE.
    You can also search for the timestamp that is part of each log file name. It is of the format MMddhhmm (Month/day/hour/minute)
    Refer also to the Troubleshooting chapter of the Installation Guide for additional details on reports and log files used by Java SE

  • Photoshop does not open file sent from LR

    Photoshop CS6 Extended does not open files sent from Lightroom. 4.4 on Win 7. What is wrong? PS starts but instead in LR the error "Could not open Photoshop' appears.

    BTW, I tried moving the Editor app from the support file into the app folder per fixes on this issue in the past.

  • Unable to view Hard and Soft Returns

    I've upgraded to 09 for Keynote and I can no longer see the lighter blue icons indicating hard and soft returns which allow control for my copy flow when animating the text. How do I make these viewable again?

    Try deleting the iCloud account, then sign back in.

  • How can I completely remove iTunes and all associated files/programs from my Windows PC?

    How can I completely remove iTunes and all associated files/programs from my Windows PC?

    iTunes, along with Quick Time, iCloud, Apple Software Update, Bonjour, Apple Mobile Device Support and Apple Application Support can all be removed from your PC by uninstalling them using 'Uninstall or change a program' in Control Panel. The only obvious thing that will be left behind is your iTunes library which remains untouched. If you want to remove that as well it's just a question of deleting it.
    Hope that helps.

Maybe you are looking for

  • How do I config "Roaming" Phones on Multisite UC500

    I have two UC520's in two geographically different locations with 7970G handsets configured. Site 1: 192.168.10.xx Site 2: 192.168.20.xx Intersite dialing works just fine and Multisite is configured via CCA with status of UP. I have one user who will

  • How do I install CS6 on new computer?

    where can I download the entire Design and Web Premium suite (as a whole) and do I need to deactivate the license of the old laptop?

  • Migration Assistant between two MacBook Pros, both running 10.9.2

    I need to migrate specific apps and data from one MacBook Pro (2.6 GHz Core 2 Duo) to another (2.5 GHz Core 2 Duo), but I don't want to migrate the entire system and all data -- largely because the "Source" HD is 1TB, and the "Destination" HD is 320G

  • Problem araised in  adding two custom fields to ksb1 tcode.

    hi experts,   I added tow fields vendor no, vendor name to Tcode:KSB1. i used user-exit :   coomep01 . in this exit i added two fields to ci_rkpos (include table) . i.e zlifnr,zname1. but that problem is ci_rkpos is not appearing in green color it me

  • Linking a Raw Material Vendor to Specific Customer

    Hi, How to link raw material vendor to a specific customer in SAP. In make to order cycle, PR generated has reference of the Sales Order. So when this PR is converted to PO, the system should only allow the user to create the purchase order for the v