BlueJ controlling memory inside of software or method - java

For my final project I made a game using mostly LibGDX, JavaFX and some networking imports, I dealt with deleting everything once it was used to save as much memory as possible and it runs completely smooth on my home laptop. However the computer in school in which I have to present on crashes at the boss with java.lang.OutOfMemoryError: Java heap space
Now I know you can do stuff like java –Xmx128m YourClassNameHere when running from cmd, but I don't have access to cmd and I cannot manually change the java settings of the computer as they all require admin access.
Is there anyway to run –Xmx128m from inside my method, or in some parameter in BlueJ ?. I've searched through the preferences and settings of BlueJ but couldn't find anything of use.

Related

Java jvm crashes without reason - runs with admin privileges

I've already tried to re-install Java several times, but it keeps crashing once starting my application. Other applications work fine (e.g. Scenebuilder).
The JVM returns no error log file, the only thing that's possible to grab are:
WERF81A.tmp.WERInternalMetadata.xml
WER403.tmp.dmp
WER461.tmp.cab
WER3D3.tmp.appcompat.txt
The hs_error_* file is missing completly (or I can't locate it).
This is part of WERF81A.tmp.WERInternalMetadata.xml
<ProcessInformation>
<Pid>6740</Pid>
<ImageName>javaw.exe</ImageName>
<CmdLineSignature>00000000</CmdLineSignature>
<Uptime>6105</Uptime>
<ProcessVmInformation>
<PeakVirtualSize>4891078656</PeakVirtualSize>
<VirtualSize>4882821120</VirtualSize>
<PageFaultCount>82469</PageFaultCount>
<PeakWorkingSetSize>195358720</PeakWorkingSetSize>
<WorkingSetSize>183607296</WorkingSetSize>
<QuotaPeakPagedPoolUsage>277440</QuotaPeakPagedPoolUsage>
<QuotaPagedPoolUsage>261216</QuotaPagedPoolUsage>
<QuotaPeakNonPagedPoolUsage>43232</QuotaPeakNonPagedPoolUsage>
<QuotaNonPagedPoolUsage>43168</QuotaNonPagedPoolUsage>
<PagefileUsage>564998144</PagefileUsage>
<PeakPagefileUsage>574984192</PeakPagefileUsage>
<PrivateUsage>564998144</PrivateUsage>
</ProcessVmInformation>
</ProcessInformation>
<ProblemSignatures>
<EventType>APPCRASH</EventType>
<Parameter0>javaw.exe</Parameter0>
<Parameter1>7.0.250.17</Parameter1>
<Parameter2>51c4b1ff</Parameter2>
<Parameter3>USER32.dll</Parameter3>
<Parameter4>6.2.9200.16420</Parameter4>
<Parameter5>505a9a92</Parameter5>
<Parameter6>c0000005</Parameter6>
<Parameter7>000000000003185a</Parameter7>
</ProblemSignatures>
The windows error reporting dialog gives me 2 options:
Debug -> negative exit code
Close -> exit code 255
The application uses the latest jdk7u25.
The application uses JavaFX 2 (so does working Scenebuilder application). There's no error logs or codes other than posted above!
The application will work if run as admin!
Any help appreciated.
Windows 8 x64
Runs on other computers without any problems.
UAC is turned off
Crash is reproducible. 2-3 Seconds after application gui shows up.
I would post this as a comment but I don't have enough rep. First of all can you tell us the version of windows you are running? 98/2000/XP/Vista/7/8?
Take your application to another computer (with the same OS) and see if it crashes too. If yes try another OS from a different family (linux/mac). If the problem is isolated to a particular family of OS then the problem might be dependent to a particular method call in your program. If its just your computer then it becomes much harder to debug. If this problem happens to all OS families then suspect a JVM bug.
If your using Windows Vista/7, try turning off UAC. Something about your user profile privileges might be blocking java from accessing a critical library (from the error dump User32.dll?). If this does solve you problems, once again experiment on yours and another computer with different UAC levels and check if the problem is isolated to a particular machine/UAC level.
Monitor both your system memory and your heap size during application startup, it may just be that your application actually filled out all the available RAM that the JVM didn't have memory to produce a hs_error_* file (this has happen to me before).
If all else fails, I recommend using a debugger to determine where the application fails. Maybe stick a System.exit(0); at different parts of your program to see if it executes to that part before crashing. Also determine if the crash is predictable (i.e fails at the same point vs randomly failing). A predictable crash suggests something in the code triggering the crash. If you are using JNI, temporarily disable them with dummy methods to see if the crash still happens.
Thats all I can really say... It can be a billion reasons, hope you find the one.

Strategies for debugging a runtime Java crash that runs correctly in NetBeans

Sorry in advance. This is a really vague question because I have no idea whatsoever what is going on. I have a Java Swing GUI desktop app that I wrote in NetBeans. While inside of NetBeans, the app works fine and passes all of the tests that I have thrown at it. I've been developing this app over the past several months, deploying it at various phases of its development.
Yesterday, I finished adding and testing some new functionality. I built the application and put it on another computer. I then went to run the program (outside of NetBeans) straight from the jar file. While in the new areas (JDialog boxes), the program crashes. Since I am not in an IDE, I have no feedback to see what is wrong.
The only thing that I can think of (and this is lame) is that I added some switch statements that switch on strings, which I know to new to 1.7. I was previously developing in 1.6. Otherwise, I can think of no reason that the program should work flawlessly inside the IDE, but crash outside of it.
Can anyone offer any suggestions for how I should approach this? I'm at a complete loss.
Thanks very much.
The next debugging step for you is reducing the size of your program until it doesn't crash, then seeing what change you made worked. That should either make the answer obvious or give you a good question to post on SO.
Your idea that it might have to do with switch statements tells you to try:
removing them
removing and compiling on JDK 6 and see if it works
Those are reasonable ways to reduce your program size to see if you can make it run.
I would start from collecting a crash dump data.
If you run the UI on windows you could use DrWatson
If you run the UI in Linux , By default the heap dump is created in a file called java_pidpid.hprof in the working directory of the VM. unless you specify the path yourself by adding this -XX:HeapDumpPath= option to your UI java options.

How do I bring a Java application to the front on a Mac?

I have a Java application that I want to bring to the front at regular intervals, but I haven't been able to do this.
[Aside to people wanting to offer user interface advice. Yes, this is normally horrible, but I'm the only one using the app. It's my time&billing app, and I'm tired failing to record billable hours!]
I've tried with AppleScript, and have no problem getting Firefox to do this, with the following script:
tell application "Firefox"
repeat
activate
delay 10
end repeat
end tell
But I don't know how reference a Java app in AppleScript (that is, I don't know what to put for the appication's name).
tell application "java" doesn't work (and there may be several Java apps running).
tell application "NameShowingInMenu" doesn't work, either.
I've tried setting "-Xdoc:name", that works for setting the name shown in the menu, but not for a "tell" target.
Any ideas?
I was able to do this, using the "Jar Bundler" app, which is included with Max OS X.
Once I packaged my code using that, it behaved as a standard mac application and the script in my original question worked with no problems.
If you can do this in the Java app itself, you could get a hint from:
How to bring a window to the front?

Java applet white screen

I'm trying to get to the bottom of a problem with our Java applet based program. It quite regularly seizes up with an unresponsive GUI (or a white screen). This of course only happens when deployed at a customer site :-(. They are running a version of the Sun JVM in 1.5 series (not sure the exact release).
We have a theory that it's to do with the applet running out of heap space - does that sound plausible? The other thing that I have set up on my machine is disabling direct draw, but that was mainly to avoid weird artefacts on other applications.
They are seeing the problem on Citrix and on regular PCs, but obviously there is a limit to what the users on Citrix can do.
Any suggestions?
Running out of heap space should cause an OutOfMemoryError to be thrown. This case sounds like a typical deadlock. To find where that is you want a stack dump of all the threads. IIRC< you can do it through the console, or from IIRC 1.6 the JDK includes jps and jstack.
First of all ensure the customer uses the latest release of the JVM they are using, and make them enable the Java console inside their browser (this requires some research from you).
Then when it happens again, tell them to look at the console window and cut-paste the contents in a mail to you.
In order to solve the problem, you must first be able to reproduce the problem. You will need an identical system in order to troubleshoot this, making one change at a time while keeping everything else equal to determine the cause(s).
Just to add to this answer (to build the knowledge base as I'm currently looking into this).
There's (at least) 2 distinct white screens related to applets.
Deadlock (as mentioned by Tom) - area will not refresh when you drag a window in front of it, so you get the strange tails left effect.
VM crash - area will become white, Java VM closes (search for hs_err_pid*.log, location dependent on browser)

Java application crashes when starting full screen application

I have a small Java application that starts a small Jetty server. This usually works great.
Unfortunately, when I start a completely unrelated, non-Java full screen game (I tried with World of Warcraft and SW: TOR), the app immediately crashes. It does not leave a hs_err log file to tell me why. It simply dies with the Windows "This app has stopped working"-dialog. The game itself continues running fine. It crashes on any game I've tried, but not on full screen video players. It crashes both if started from Eclipse and from command line. I haven't been able to reproduce this with another Java application, from simple to very large ones. When I start WoW in fullscreen (windowed) mode, the app continues running fine, so it seems this is triggered by having a full screen app that takes control of the entire desktop.
It seems like that for some reason the JVM crashes when my video card starts doing something.
Does anyone have an idea why this crash happens, or how I can figure out why it does? I'm not sure how starting a completely unrelated application (video driver maybe?) would interfere with my JVM.
You can try to monitor it with visual vm. Also try to write a heap dump when the vm crashes and analyse it afterwards. Maybe then you will get an idea of what happens.
Can Sun JDK generate core/heap dump files when JVM crashes?
Tried any newer Java version?
Is yours game Warcraft and SW: TOR game is running concurrently? Do you mean that you are running yours game build under java and at that instance you started another game Warcraft and SW: TOR? Which operating system and which version of J V M are you using?May be the two different program is having different priority for graphics resources.It not clear that the game Warcraft and SW: TOR is build under which platform .May be the operating system default priority of thread scheduling is working behind for using graphics resources.It seems like JV M is throwing system exception for not finding the resource and terminating .May be you should check the availability of resources and if it is available proceed forward.

Resources