开发者

I need a solution to starting Slick 2D/LWJGL Java project via command line. Help?

Currently I am starting my Slick 2D application via this batch file-

java -Djava.library.path=lib -Xms512m -Xmx512m -jar myapp.jar %1

Where lib is the folder that contains the LWJGL/Slick libraries and myapp.jar is my application.

Although this is easy and effective I want to be able not to have to run a script all the time and actually create a java .jar to do this.

So my question is, h开发者_Go百科ow would I 'convert' this batch script into Java code?


Why you would want Java code for this is beyond me as that creates exactly the same problem for you again – namely running your startup Java program that then starts another Java program; you'd be at the same point as before.

However, you don't need to create a JAR in any case. You can stuff all your compiled .class files somewhere and set that as the classpath. A JAR is little more than a main class and a classpath bundled into one.

So instead of your invocation above you can then use

java ... -cp %USERPROFILE%\Java\MyApp myapp.gui.Main

or something like that. Set the classpath with -cp and give the main class on the command line instead of the JAR.


Any -D command line arguments can be set via java.lang.System.setProperty. But the memory parameters can't be set from inside a JVM as far as I know. Therefore, there is no way to do what you want.

Instead you could generate e.g. a Windows executable with JSmooth. Such a wrapper should be able to set all JVM arguments. But in the end the situation is similar to the script. You have some kind of wrapper.


The easiest way is to use a program like JarSplice (http://ninjacave.com/jarsplice)

You can easily create a jar executable with all needed lib. it works very well

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜