Java Questions

Java Questions

imagem de Red27 Studios
Hi there, I am *almost* ready to submit my Java Game to AppUp, but have two questions that I am struggling to find an answer for: 1) How do I specify the Java Heap Size? I have specified -Xmx512m in the "Program arguments" in Step 2 of the Software Packaging Utility for Java, but it does not appear to be used since I am getting Out Of Memory errors. 2) I need to use File IO to save game progress and preferences etc - is this permitted? If so, where does the output default to? Thanks and regards, Red27.
15 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de norman-chou (Intel)

Question 2

Saving files to the device is perfectly accepted, however the location may need to change depending on windows xp and windows 7.
Windows XP, you can save it to programs files folder.

Windows 7, you CAN NOT save it to the Programs Files folder, you can save it to Programs Data folder. The new security levels on windows 7 won't allow apps to save files to Programs Files folder.

Some developer don't want to have two different versions on where to save the folder, so you can also save it to your own application folder you create. Such as C:\My App Files.

imagem de Data Virtue

I've used that method with installs on my other software. When Vista/7 came out I started getting user complaints. So I made the installer default to 'C:\Nevitium', no more complaints. Microsoft makes a big deal out of applications not writing to program files. I never understood why they just didn't limit the application to accessing the startup folder in Program Files. I just assumed they were trying to make it hard for cross-platform applications. On top of that, I've been removing viruses that house themselves in the new and approved 'Application Data' folder. So the security argument kind of gets thrown out.

I personally hate being told where to place my data on a PC. I keep all my important data off the root. I also try to setup my applications so they don't rely on the registry, if possible. Anything you want to run from a flash drive can't rely on the registry. I've seen the popularity of this setup--applications running from flash drives--grow in recent years. As a developer, I consider the registry off-limits to me unless I need to deploy a service or other boot time program on windows. The registry is better left to mundane things like uninstall entries and file associations. Real Player, I know, generates over 1mb of registry bloat, iTunes is worse.

imagem de Red27 Studios

Any news on when this problem will be resolved guys?

imagem de Red27 Studios

Hi Guys,

I appreciate that there is a potential workaround for the Java -Xmx problem, but I'd definitely like a ball park estimate of when it will be resolved and released. Any ideas?

Regards,

Pete.

My vote on this too. Being able to pass Java runtime parameters is very important. One of my apps won't run correctly without turning off sun.java2d.d3d off.

imagem de Pradeep Saran

How to develop Java app for Intel ?? Given me step by step Procedure... Or Video Tutorial.. Pls

http://www.devsaran.com
imagem de DG Rooven (Intel)

Hello.

You will find more information about the SDK and more resources on this link: http://appdeveloper.intel.com/en-us/article/intel-appup-java-sdk-overview

I hope this will be helpful.

Regards
Rooven

Intel AppUp™ Center
Intel AppUp(SM) Developer Program

Regards, DG Rooven
imagem de Red27 Studios

Thanks for the reply.

However, I use relative files.....at start up of the game I attempt to locate or create a User\ directory (based on location of app), and then a config file within there, plus a User\Save directory for save games and User\Game Highlights directory, a User\Log directory etc. So despite using this relative system, I am failing to identify what is happening, since I don't know where the Validator believes the "root" directory is.

I don't want to save to a folder like C:\My App - I (and I think users) hate that kind of approach cluttering up the C:\ :-)

Finally, any idea re: Question 1 - it seems like a potential problem if there's no easy way around specifying the heap...

Cheers,

Red27.

imagem de Red27 Studios

Thanks for the reply.

However, I use relative files.....at start up of the game I attempt to locate or create a User\ directory (based on location of app), and then a config file within there, plus a User\Save directory for save games and User\Game Highlights directory, a User\Log directory etc. So despite using this relative system, I am failing to identify what is happening, since I don't know where the Validator believes the "root" directory is.

I don't want to save to a folder like C:\My App - I (and I think users) hate that kind of approach cluttering up the C:\ :-)

Finally, any idea re: Question 1 - it seems like a potential problem if there's no easy way around specifying the heap...

Cheers,

Red27.

Hi Red27 Studios

For question 1

Looks like your application is using heap size > 512 MB.
Can you please try this command line, "-Xms512m -Xmx1024m" and see is that fixes the issue. If not you can try till 2GB ("-Xms512m -Xmx1024m")
as this is the max limit for Jvm on a Windows machine. Please let me know if that fixes your issue.

Thanks,
Praveen

Hi Red27 Studios

For question 1

Looks like your application is using heap size > 512 MB.
Can you please try this command line, "-Xms512m -Xmx1024m" and see is that fixes the issue. If not you can try till 2GB ("-Xms512m -Xmx1024m")
as this is the max limit for Jvm on a Windows machine. Please let me know if that fixes your issue.

Thanks,
Praveen

imagem de Red27 Studios

No, that's not the problem. I don't believe the Heap is getting the chance to extend anywhere near 512mb - it bombs out closer to 128m since the -Xmx parameter is never read.

I believe this is because the Packaging Application does not allow VM parameters to be specified - it only allows Program parameters (i.e specify the parameters that are read in at runtime as the String args[] of the main() method).

I suspect this needs to be looked at urgently, since none of the larger Java Apps/Games would be able to run on AppUp if my theory is correct.

However on a more positive note, re: the File IO, I have decided to just use System.getenv("APPDATA") with the name of my game appended (this results in the user data being written to C:\Users\YourUserName\AppData\Roaming\YourGameName\ under Windows Vista)

Thanks,

Pete.

Hi Peter,

Currently, Set extra JVM parameter is not support (the only support JVM parameter is “–D” (system properties)) right now.

BTW, special for below case, there may be one workaround for this issue: Create a Java application launching wrapper (it is a jar file, use it as Main Jar in SDK packaging utility, and package your Game’s jar file as additional jar file), After AppUp client launch the Java application launching wrapper, the wrapper will create a new java process (the JRE path can be retrieved from java.home system property) with your special JVM parameter to launch your Game’s jar file.

Below is a simple reference for the launching wrapper:
import java.io.IOException;

public class AdpLauncher {

/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
// get java.exe
String javacmd = System.getProperty("java.home") + "\\bin\\java.exe";
// get the path
String path = java.net.URLDecoder.decode(AdpLauncher.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "utf-8");
path = path.substring(1, path.lastIndexOf("/"));

// the cmd array
String[] cmdArray = {
javacmd,
"-Xmx512m",
"-jar",
path + "/AppName_lib/XXX.jar" // Note: it is require to replace "AppName" with your java launching wrapper jar file name (remove “.jar”. e.g. if Main Jar is “YYYY.jar”, you need replace with “YYYY”), “XXX.jar” is the developer’s real runnable jar (e.g. the game jar file)
};

// create the process
Runtime.getRuntime().exec(cmdArray);
}

}

Hop this helps

imagem de Red27 Studios

Thanks for the response.

I tried this method, but cannot get it to work.

I have created a Launcher.jar file which contains the AdpLauncher, and have added my game jar (XXX.jar) as a required file via the Packager, and specified the path as /Launcher_lib/XXX.jar, but nothing happens on launch of the Validator - AdpLauncher is seemingly run, but the process being exec'ed does nothing - it's as though the java.exe command does nothing/returns nothing, so I have no output to try and ascertain what happened - I merely get the Validator straight away asking "did it launch successfully?"

As an aside, where does the Validator tool extract the contents at runtime - perhaps I can try and command line launch from there?

Finally, do you know when an emergency fix for this problem (to allow -Xmx parameters) can be made available? Even as beta I'd be happy to test - I'm desperate to get the game in the AppUp store! :-(

Thanks,

Pete.

Faça login para deixar um comentário.