Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Creating Jar from Applet  (Read 1092 times)
0 Members and 1 Guest are viewing this topic.
Offline Funkymonk

Junior Newbie





« Posted 2007-07-22 23:49:22 »

I made an applet and I want to stick it in a jar but I guess there is no way to execute the jar because the applet does not have a main method. Is there another way to make another class with a main method that just executes the applet?
Also, I want to use proguard to obfuscator my applet. Can I use it without being able to make a jar file out of my applet?

Thanks
Offline keldon85

Senior Duke


Medals: 1



« Reply #1 - Posted 2007-07-23 00:19:10 »

You can recode your implementation so that a component/canvas is placed into the applet, and can also be placed in a frame. That is what I've been doing, and it works perfectly fine.

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #2 - Posted 2007-07-23 00:20:24 »

>Is there another way to make another class with a main method that just executes the applet?

Yes. Create a (j)frame, instantiate the applet, add it to the frame, init it. However, there may be some issues if you rely on the document base etc.

Alternatively you can use webstart to launch some applet.

>Can I use it without being able to make a jar file out of my applet?

Eh... Huh

Well, you can use proguard or any other obfuscator. The entry points aren't affected in any way (if the obfuscator works as intended).

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Funkymonk

Junior Newbie





« Reply #3 - Posted 2007-07-24 00:53:02 »

Ok, I think I got everything figured out. I am having a problem with this one method used to play my audio files:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
public void loadAu(String filepath)
    {
        try
        {
           InputStream in = getClass().getResourceAsStream(filepath);
           AudioInputStream stream = AudioSystem.getAudioInputStream(in);
           AudioFormat format = stream.getFormat();
           if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED)
           {
                 format = new AudioFormat(
                    AudioFormat.Encoding.PCM_SIGNED,
                    format.getSampleRate(),
                    format.getSampleSizeInBits()*2,
                    format.getChannels(),
                    format.getFrameSize()*2,
                    format.getFrameRate(),
                    true);
                 stream = AudioSystem.getAudioInputStream(format, stream);
           }
   
           DataLine.Info info = new DataLine.Info(
            Clip.class, stream.getFormat(), ((int)stream.getFrameLength()*format.getFrameSize()));
           clip = (Clip) AudioSystem.getLine(info);
           clip.open(stream);
           clip.addLineListener(this);
           stream.close();
   
        }
        catch (MalformedURLException e){e.printStackTrace();}
        catch (IOException e){e.printStackTrace();}
        catch (LineUnavailableException e){e.printStackTrace();}
        catch (UnsupportedAudioFileException e){e.printStackTrace();}
    }


It throws an IOException when It is in a jar and when I call it with the parameter "Audio/file.au" Audio being the subdirectory and Audio.au being the audio file. It works when I use it in Bluej or in Eclipse. This is the exact error:

1  
2  
3  
4  
5  
6  
7  
java.io.IOException: mark/reset not supported
   at java.util.zip.InflaterInputStream.reset(Unknown Source)
   at java.io.FilterInputStream.reset(Unknown Source)
   at java.io.FilterInputStream.reset(Unknown Source)
   at com.sun.media.sound.WaveFileReader.getFMT(Unknown Source)
   at com.sun.media.sound.WaveFileReader.getAudioInputStream(Unknown Source)
   at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
Offline broumbroum

Junior Duke





« Reply #4 - Posted 2007-07-24 04:16:18 »

mark/reset are not suported by original InputStreams, therefore you must buffer the Stream throughout some Buffered instance from java IO or NIO. I'd use a BufferedInputStream for the resource.
1  
2  
3  
InputStream in = getClass().getResourceAsStream(filepath);
           AudioInputStream stream = AudioSystem.getAudioInputStream(new BufferedInputStream(in));
           AudioFormat format = stream.getFormat();
   Grin

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline DzzD
« Reply #5 - Posted 2007-07-24 11:06:30 »

The simplest way and also a way that will enable you to easily convert any applet to Application is to write a JavaAppletViewer in java:

this thread may interest you:

http://www.java-gaming.org/forums/index.php?topic=17028.0

I do not have source code right now but I will post it or send me an email i will sent this code back to you


Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (42 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!