JWrapper build not running correctly.

Yep well I pretty much am. The build goes through successfully, but the app does not run.

.json:


{
    "platform": "windows",
    "jdk": "C:/dev/resources/OpenJDK/openjdk-1.7.0-u60-unofficial-windows-i586-image.zip",
    "executable": "testapp",
    "appjar": "C:/dev/testapp/testapp.jar",
    "mainclass": "com/badlogicgames/packr/TestApp",
    "vmargs": [
        "-Xmx1G"
    ],
    "resources": [
        "pom.xml",
        "src/main/resources"
    ],
    "minimizejre": "soft",
    "outdir": "build"
}

I know resources is optional but I thought I’d try it to see if it made any difference.

Well jesus H christ after doing some research on what a “POM” is, I finally am able to build the example project and it runs from the .exe!

Thank you lord maven ::slight_smile:

Hi Dreamtime

I made the game window appeared. It repeated every time I ran 32 bit or 64 bit - exe. Though I’ve seen no console output when running the exe. It’s appearing only when i simply run the jar.
It happened after I modified the sources:

Game.java:


package game;

import javax.swing.*;
import java.awt.*;


public class Game
{
    Draw draw;
    Frame frame;
    Insets insets;

    boolean isRunning = true;


    private int FPS = 30;
    private double averageFPS;

    public static void main( String[] args )
    {
        System.out.println( "Hello! "+  Thread.currentThread() );
        Game game = new Game();
        game.run();
//
        //   System.exit( 0 );
    }

    void run()
    {
        final Runnable doHelloWorld = new Runnable()
        {
            public void run()
            {
                System.out.println( "Hello World on " + Thread.currentThread() );
            }
        };

        Thread appThread = new Thread()
        {
            public void run()
            {
                try
                {
                    SwingUtilities.invokeLater( doHelloWorld );
                    initialize();

                    long startTime;
                    long URDTimeMillis;
                    long waitTime;
                    long totalTime = 0;

                    int frameCount = 0;
                    int maxFrameCount = 30;

                    long targetTime = 1000 / FPS;

                    while ( isRunning )
                    {
                        startTime = System.nanoTime();

                        update();
                        draw();

                        URDTimeMillis = ( System.nanoTime() - startTime ) / 1000000;

                        waitTime = targetTime - URDTimeMillis;

                        try
                        {
                            Thread.sleep( waitTime );
                        }
                        catch ( Exception e )
                        {

                        }

                        totalTime += System.nanoTime() - startTime;
                        frameCount++;

                        if ( frameCount == maxFrameCount )
                        {
                            averageFPS = 1000.0 / ( ( totalTime / frameCount ) / 1000000 );
                            frameCount = 0;
                            totalTime = 0;
                        }

                    }

                    frame.close();
                }
                catch ( Exception e )
                {
                    e.printStackTrace();
                }
                System.out.println( "Finished on " + Thread.currentThread() );
            }
        };

        appThread.start();
    }

    void initialize()
    {
        draw = new Draw();
        frame = new Frame();

        frame.add( draw );
    }

    void update()
    {
    }

    void draw()
    {
        System.out.println( "Game running on " +  Thread.currentThread()  );
        //frame.draw();
    }
}

Frame.java:


package game;

import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Frame extends JFrame
{
    int windowWidth = 960;
    int windowHeight = 480;
    Insets insets;

    public Frame()
    {
        setTitle( "Game" );
        setSize( windowWidth, windowHeight );
        setResizable( false );
        //  setDefaultCloseOperation( EXIT_ON_CLOSE );
        setDefaultCloseOperation( DO_NOTHING_ON_CLOSE );
        addWindowListener( new WindowAdapter()
        {
            /**
             * Invoked when a window is in the process of being closed.
             * The close operation can be overridden at this point.

             * @param e
             */
            @Override
            public void windowClosing( WindowEvent e )
            {
                System.out.println( "Good Bye World on " + Thread.currentThread() );
                System.exit( 0 );
            }
        } );

        insets = getInsets();
        setSize( insets.left + windowWidth + insets.right, insets.top + windowHeight + insets.bottom );

        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation( dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2 );

        setVisible( true );
    }


    public void close()
    {
        setVisible( false );
    }
}

I modified also jwrapper.xml a bit but I think it does no affect the result in fact because I’ve ran the xml with initial build without the success.

Hey Stranger

Packr seems to do the trick. Thanks for your effort
I could also run the jar, but I don’t know how to configure jwrapper properly.
Packr seems to do the job better and for free/no branding anyway

I’ve tested the .exe only on one other pc but it seems to work fine.
This is just the example app though, now I’m going to try and build my own app with packr and maven.

I’d like to clarify the things.

I meant that I made win-offline.exe working (game’s jframe appears) after modification the java sources.