How do I make a batch file if the .class file uses a foreign package?

I am trying to make an MS-DOS batch file using the bytecode file from the Java source file, called AddFields.java. This program uses the package BreezySwing; which is not standard with the JDK. I had to download it seperately. I will come back to this batch file later.
But first, in order to prove the concept, I created a Java file called Soap.java in JCreator. It is a very simple GUI program that uses the javax.swing package; which does come with the JDK. The JDK is currently stored in the following directory: C:\Program Files\Java\jdk1.6.0_07. I have the PATH environment variable set to the 'bin' folder of the JDK. I believe that it is important that this variable stay this way because C:\Program Files\Java\jdk1.6.0_07\bin is where the file 'java.exe' and 'javac.exe' are stored. Here is my batch file so far for Soap:
@echo off
cd \acorn
set path=C:\Program Files\Java\jdk1.6.0_07\bin
set classpath=.
java Soap
pause
Before I ran this file, I compiled Soap.java in my IDE and then ran it successfully. Then I moved the .class file to the directory C:\acorn. I put NOTHING ELSE in this folder. then I told the computer where to find the file 'java.exe' which I know is needed for execution of the .class file. I put the above text in Notepad and then saved it as Soap.bat onto my desktop. When I double click on it, the command prompt comes up in a little green box for a few seconds, and then the GUI opens and says "It Works!". Now that I know the concept of batch files, I tried creating another one that used the BreezySwing package.
After I installed my JDK, I installed BreezySwing and TerminalIO which are two foreign packages that make building code much easier. I downloaded the .zip file from Lambert and Osborne called BreezySwingAndTerminalIO.zip. I extracted the files to the 'bin' folder of my JDK. Once I did this, and set the PATH environment variable to the 'bin' folder of my JDK, all BreezySwing and TerminalIO programs that I made worked. Now I wanted to make a batch file from the program AddFields.java. It is a GUI program that imports two packages, the traditional GUI javax.swing package and the foreign package BreezySwing. The user enters two numbers in two DoubleField objects and then selects one of four buttons; one for each arithmetic operation (add, subtract, multiply, or divide). Then the program displays the solution in a third DoubleField object. This program both compiles and runs successfully in JCreator. So, next I moved the .class file from the MyProjects folder that JCreator uses to C:\acorn. I put nothing else in this folder. The file Soap.class was still in there, but I did not think it would matter. Then I created the batch file:
@echo off
cd \acorn
set path=C:\Program Files\Java\jdk1.6.0_07\bin
set classpath=.
java AddFields
pause
As you can see, it is exactly the same as the one for Soap. I made this file in Notepad and called it AddFields.bat. Upon double clicking on the file, I got this error message from command prompt:
Exception in thread "main" java.lang.NoClassDefFoundError: BreezySwing/GBFrame
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
4)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Caused by: java.lang.ClassNotFoundException: BreezySwing.GBFrame
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 12 more
Press any key to continue . . .
I know that most of this makes no sense; but that it only means that it cannot find the class BreezySwing or GBFrame (which AddFields extends). Notice, however that it does not give an error for javax.swing. If I change the "set path..." command to anything other than the 'bin' folder of my JDK, I get this error:
'java' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .
I know this means that the computer cannot find the file 'java.exe' which I believe holds all of the java.x.y.z style packages (native packages); but not BreezySwing or any other foreign packages. Remember, I do not get this error for any of the native Java packages. I decided to compare the java.x.y.z packages with BreezySwing:
I see that all of the native packages are not actually visible in the JDK's bin folder. I think that they are all stored in one of the .exe files in there because there are no .class files in the JDK's bin folder.
However, BreezySwing is different, there is no such file called "BreezySwing.exe"; there are just about 20 .class files all with names like "GBFrame.class", and "GBActionListener.class". As a last effort, I moved all of these .class files directly into the bin folder (they were originally in a seperate folder called BreezySwingAndTerminalIO). This did nothing; even with all of the files in the same folder as java.exe.
So my question is: What do I need to do to get the BreezySwing package recognized on my computer? Is there possibly a download for a file called "BreezySwing.exe" somewhere that would be similar to "java.exe" and contain all of the BreezySwing packages?

There is a lot of detail in your posts. I won't properly quote everything you put (too laborious). Instead I'll just put your words inside quotes (").
"..there are some things about the interface that I do not like."
Like +what?+ This is not a help desk, and I would appreciate you participating in this discussion by providing details of what it is about the 'interface' of webstart that you 'do not like'. They are probably misunderstandings on your part.
"Some of the .jar files I made were so dangerously corrupt, that I had to restart my computer before I could delete them."
Corrupt?! I have never once had the Java tools produce a corrupt Jar. OTOH, the 'cannot delete' problem might relate to the JRE gaining a file lock on the archive at run-time. If the file lock persisted after ending the app., it suggests that the JRE was not properly shut down. This is a bug in the code and should be fixed. Deploying as .class files will only 'hide' the problem (from casual inspection - though the Task Manager should show the orphaned 'java' process).
"I then turned to batch files for their simple structure and portability (I managed to successfully transport a java.util containing batch file from my computer to another). This was what I did:
- I created a folder called Task
- Then I copied three things into this folder: 1. The file "java.exe" from my JDK. 2. The program's .class file (Count.class). and 3. The original batch file.
- Then I moved the folder from a removable disk to the second computer's C drive (C:\Task).
- Last, I changed the code in the batch file...:"
That is the +funniest+ thing I've heard on the forums in the last 72 hours. You say that is easy?! Some points.
- editing batch files is not scalable to 100+ machines, let alone 10000+.
- The fact that Java worked on the target machine was because it was +already installed.+ Dragging the 'java.exe' onto a Windows PC which has no Java will not magically make it 'Java enabled'.
And speaking of Java on the client machine. Webstart has in-built mechanisms to ensure that the end user has the minimum required Java version to run the app. - we can also use the [deployJava.js|http://java.sun.com/javase/6/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit] on the original web page, to check for minimum Java before it puts the link to download/install the app. - if the user does not have the required Java, the script should guide them through installing it.
Those nice features in deployJava.js are available to applets and apps. launched using webstart, but they are not available for (plain) Jar's or loose class files. So if 'ensuring the user has Java' is one of the requirements for your launch, you are barking up the wrong tree by deploying loose class files.
Note also that if you abandon webstart, but have your app. set up to work from a Jar, the installation process would be similar to above (though it would not need a .bat file, or editing it). This basic strategy is one way that I provide [Appleteer (as a downloadable ZIP archive)|http://pscode.org/appleteer/#download]. Though I side-step your part 1 by putting the stuff into a Jar with the path Appleteer/ - when the user expands the ZIP, the parts of the app. are already in the Appleteer directory.
Appleteer is also provided as a webstart launched application (and as an applet). Either of those are 'easier' to use than the downloadable ZIP, but I thought I would provide it in case the end user wants to save it to disk and transport the app. to a machine with no internet connection, but with Java (why they would be testing applets on a PC with no internet connection, I am not sure - but the option is there).
"I know that .jar and .exe files are out because I always get errors and I do not like their interfaces. "
What on earth are you talking about? Once the app. is on-screen, the end user would not be able to distinguish between
1) A Jar launched using a manifest.
2) A Jar launched using webstart.
3) Loose class files.
Your fixation on .bat files sounds much like the adage that 'If the only tool you have is a hammer, every job starts to look like a nail'.
Get over them, will you? +Using .bat files is not a practical way to provide a Java app. to the end user+ (and launching an app. from a .bat looks quite crappy and 'second hand' to +this+ user).
Edit 1:
The instructions for running Appleteer as a Jar are further up the page, in the [Running Appleteer: Application|http://pscode.org/appleteer/#application] section.
Edited by: AndrewThompson64 on May 19, 2009 12:06 PM

Similar Messages

  • How do i make it so iTunes plays the music files from where i have chosen to store them?

    how do i make it so iTunes plays the music files from where i have chosen to store them as opposed to it scattering copies of my files into a myriad different folders based on the albums they came from when i'm not even interested in keeping whole albums?
    I recently converted myself to mac after having been a windows formatted person since the beginning of time. I use last.fm and the client scrobbler only supports iTunes on the mac (scobbling since Nov 06 and i'm now heavily dependant upon it as a means of discovering new music) - if you don't know what that means then take it for granted i have no option other than to use iTunes as my media player whn using the mac. And almost immediately upon using iTunes i was filled with horror.
    My tale of woe as follows: I copy all my mp3 files to folder X on my new mac. I copy my simple playlist in to that same folder X. The simple playlist simply lists all the files in folder X in the order i want to hear them in... simple right? And what happens the moment i start playing my simple list? Well you probably all ready know; itunes throws copies of all those files in to the air, scatters them to the four winds so each of them fall into a little folder of their own representing the album they might once have come from. I don't keep whole albums. For me the 'album experience' is a ruse to trick one into listening to weaker material. I only keep the concentrated goodness. I only put up with albums in a previous lifetime because in the days of vinyl i had no other choice apart from spending hours compiling mix tapes. Now i am liberated from these restrictions and have been for the 15 or so years i've been using a computer to listen to music. Until along comes iTunes forcing me backwards in time, frog marching me back into the past.
    That simple list i mentioned is my one and only playlist. This single playlist has been evolving for 15 years as tracks are added and removed and their position in the list changes because that song sounds amazing when heard after that other song whereas hearing this song after that song would be like pouring custard over your sausages (for me shuffling is an abomination). And so here is how i've managed this list and managed synchronization of said list and listed files with my mp3 player (currently a Zen).
    Adding a new file: After deciding that song is a keeper i will copy it into that simple folder that holds all my music and drop it in to a position on the list i deem most suited for it. Incidentally over this entire 15 year (i'm pretty sure it's been around that long) my media player has been winamp but for the reason previously mentioned i am unable to use winamp in mac world.
    Removing a file: fortunately winamp has an option to simultaneously remove a file from the list and the hard drive. And naturally so because after all if i no longer like a song then i want it expunged completely from life or at least from my hard drive and playlist. In the brave new world of iTunes i have to remove from the list there then delete the file from where iTunes copied it from and then the place iTunes copied it to.
    Editing the list: drag an item in the list to it's preferred location and select to save it as i would for any other file using any other application... well desktop type application as opposed to one that uses a database as its primary means of storage.
    Syncing with the mp3 player: copy drag drop playlist file from the simple folder on the hard drive to the simple folder on the mp3 player as i would for any other file. And then also copy drag drop the most recently created files from simple folder on hard drive to simple folder on player after having ordered them by creation date so as to make it easier to select the most recently created. After a while the mp3 player will fill up with the files no longer on the list so i will delete all files from player then re-copy all flies from simple folder on hard drive to simple folder on mp3 player.
    I do not make changes to the list on the mp3 player so synchronization needs only to go one way: from laptop to player.
    So all very simple. Apart from editing the positions of files in the list everything is managed by copy drag dropping and deleting files using windows explorer.
    But i'm in a mac and circumstances have forced me in to the corner of using iTunes. And this whole iTunes situation is terrifying for me as over the years i've heard horror stories about it deleting all of someone's music files. Perhaps this may have been by using the software incorrectly but even so, the very fact that it appears possible for this to happen simply by using the software incorrectly and the fact that it happens with some degree of frequency given the number of reports of this happening that i have heard of over the years on music discussion forums fills me with dread that i have to now use this software. And given the software's blatant disregard for the user's choice as to where to store his/her files it's no surprise that this happens. The software is pointlessly doing dangerous things with my data. Please make it stop.
    Please can i just at the very least make iTunes play the music from the folder i have chosen to put my files in and not copy those files here there and everywhere without my say so? Thankyou.

    option discovered in preferences. Really this and any feature that moves deletes or edits a users data should as far as possible be OFF BY DEFAULT. It shouldn't by default and without the users specific say do this dangerous and unnecessary thing without even letting the user know what it's doing!!! And then cause me a few hours (as i'm new to mac) searching for the option so as to switch it off. If i hadn't noticed the status cage declaring that it was copying files then i might never have twigged that this insane thing was occurring. And if i hadn't of noticed i would have been left maintaining the contents of the folder i copied the files to, the folder which as far as i was informed and so believed was also the location of the music files i was playing. How does Apple justify this 'genius' piece of software non-design? Surely it will hurt no one if this was off by default for new users - overall at least i dare say it would cause a lot less distress in the future for the unsuspecting public at large. Thanks for the support.

  • TS4293 How can I make iMovie to show me the AVCHD files importet by iPhoto?

    My iMovie 11 shows the videos from my iPhone importet by iPhoto, but not all the videos importet the same way from my camera. It works fine with the videos recorded in MP4 but not at all with the AVCHD. How can I make iMovie to show me the AVCHD files? iPhoto imports and shows the AVCHD fine. Also I could import the AVCHD files with iMovie but then they would be twice on my computer and use a  lot of space.
    thanks for your help

    Right now, iMovie won't edit AVCHD wrapped files. You have a few options:
    1. Import the videos with iMovie. Afterwards, you may add the imported movies to iPhoto if you want.
    2. Import the videos with another app. (Too numerous to mention.)
    3. Convert the videos with a third-party tool.
    4. Wait for a future version of iMovie that adds this capability.

  • How do I make New window open maximized the way it used to?

    How do I make New window open maximized the way it used to?

    { Ctrl + B } opens and closes the Bookmarks Sidebar.

  • Manipulate a object serialized file when the .class file is missing

    I want to know if it is possible to recovery the object when its class file is missing! I guess it needs to manipulate the file and extract the values and ask user to name the values, after that, create a new class file for future use. However, I don't know how to manipulate the object serialized file. I really appreciate any hints you guys can give

    I suppose if you created the class file, with the same name, package, and unique serial ID, fields, etc, it can be done.
    Another option is to not use serialization if you are just trying to recover the data. Again you would need to know what the datatypes of the fields are to know what it is you are trying to read, how to parse serialized data, etc. Some Objects are easy to read, like Strings. The more complicated ones are the simple datatypes.

  • How do I make a bootable cd from the windows .iso file

    I am trying to install windows xp on my iMac. My univeristy gives me free copy of XP but I have to download the .iso file. I tried burning the .iso file to a cd but bootcamp says it can not recognize the cd for installation. How can a make a bootable copy of the windows xp .iso file so that I can install it on my iMac.

    You used Disk Utility I take it?
    http://en.wikipedia.org/wiki/ISO-9660
    http://www.ezbsystems.com/ultraiso/
    This is for creating a custom Vista SP1 EFI-enabled DVD:
    http://www.jowie.com/post/2008/02/Select-CD-ROM-Boot-Type--prompt-while-trying-t o-boot-from-Vista-x64-DVD-burnt-from-iso-file.aspx

  • HT1338 I made a movie in iMovie and want to make copies.  I lost the iMovie file, I just need to know how to copy a disk.  HELP!

    I made a movie in iMovie and want to make copies.  I lost the iMovie file, I just need to know how to copy a disk.  HELP!

    Not sure if you really mean disk (HD) or disc (CD/DVD).  Check out this YouTube video

  • How to make an applet to read the Text file present inside a jar

    Hi All,
    I have writen one applet named ReadFile.java which reads a text file present in the same directory and does some manipulation of text file contents.
    The applet code runs successfully when i run the applet in command prompt like
    {color:#ff0000}*java ReadFile*{color}
    And i am getting the needed results.
    Then i made a jar file with the applet code and text file as
    {color:#ff0000}*jar cvf rf.jar ReadFile.class File1.txt*{color}
    Then i have inlcuded this applet inside a html file as
    {color:#ff0000}*<applet code= "ReadFile.class" width= "500" height= "300" archive = "rf.jar" ></applet>*{color}
    after this when i load the html file, the applet code is not executed fully. Its throwing FileNotFoundException: File1.txt.
    Applet is not recognizing trhe text file present inside the jar file.
    Can any body explain me how to overcome this problem. Any setting needs to be done for making the applet indicate the presence of Text file inside the jar file.

    what code in your applet gets the text file and reads it? are you using getResource or something similar?

  • How to make the class files to run in a particular platform only

    Class files which are created from the java files should only run on a particular platform only..say i'm going to create the class files for windows environment then those class files should only run on that environment only. it should not run on unix environment etc..how to do this..

    hi,
    i cant think of a reason why you would do something like that.. You cant prevent your class files to be read by the JVM of a different OS, but anyway you could do something to stop your code from running in a different OS, for eg.
    Properties prop = System.getProperties();
    if (prop.getProperty("os.name").startsWith("Windows")==true)
          //code
    else
           System.out.println("Sorry i will not run in this OS");
    }cheerz
    ynkrish

  • How do you make "Acrobat X Pro" open the "combine pdf" window in the foreground?

    How do you make "Acrobat X Pro" open the "combine pdf" window in the foreground?
    I am using a "Windows 7" computer at work with "Acrobat X Pro" and I'm constantly combining
    pdf's and tiff's in Acrobat.
    It would be nice if when I select 30 or 40 files to combine, the
    "Combine Supported Files in Acrobat" window would open in the
    foreground, not behind the 10 or so windows already open.
    I have been researching this for some time now with no solution.
    If the answer is that "IT CAN'T BE DONE", then that's fine. At least
    I will have an answer and can stop searching. If (as I suspect) it can
    be done, then kindly supply me with "step by step" instructions.
    Michael Jones

    Something that works  (provides Acrobat the application precedence in the OS that is requisite for this) --
    Minimize the 10 or so application windows before engaging use of Acrobat's "combine".
    That'll let the Acrobat dialog windows display front and center.
    Be well...

  • How to hide the source code from the .class file

    Hi,
    By some jad tool we can recompile the .class files and get the java file corresponding to it. How to protect it?
    Anyone please help me..
    Thanks & Regards,
    N.Ravasankar

    An obfuscator can for example rename classes, variables to meaningless names, like one-letter names. And it can make some bytecode that is hard to decompile or just makes the code less readable when decompiled. Some obfuscators might even be able to do something to the code that makes decompilers not work or incorrect decompile code.

  • How do I make document relative links for the site?

    How do I make document
    relative links for the site -
    <img src="../images/foo.gif"... (for example)?

    > How do I make document
    > relative links for the site -
    look in the bottom of the "browse to file" dialog box.
    Alan
    Adobe Community Expert, dreamweaver
    http://www.adobe.com/communities/experts/

  • How to load a Jar file in the class path?

    How to load a Jar file which contains class files, images, etc.. in the classpath without using URLClassLoader.

    You don't "load" jars. If it's on the classpath, you can obtain individual resources from it using various methods on either Class or ClassLoader. Do you mean "how to add a jar to the classpath at runtime"? Can't be done without using a classloader, typically URLClassLoader or a subclass thereof. Why you want to not use the proven method is beyond me. Presumably because you don't understand classloading. In which case, forget it.

  • How can I hide the class file ??

    Hi !
    I has a question, when i write a program of Java, then use the command "javac" to compiler to class file for other people using, but the class file can be disassembled and convert to source code. How can I hide the class file and let people can not disassemble, or can not see the source code. Thinks

    See these....
    http://www.saffeine.com/
    http://www.jarsafe.com/
    I recently read this. This will help you.
    http://developer.java.sun.com/developer/qow/archive/160/index.jsp
    Enojy....
    Rajesh

  • How do I make an e-mail account the default account (I have 2 accts)?

    How do I make an e-mail acct the default account?  I want my contact list to come over to my iPad.

    To make it the default account- iPad settings, mail,(under signature) default account. Select it and change it. The address book, under that account make sure you have addresses ON.

Maybe you are looking for

  • IPad 2 hdmi connector no longer works with iOS 7.3

    Hi any one else had this issue? I have always connected my iPad 2 to my tv via a apple made hdmi connector, used mainly for fils on netflix eat. Since firmware updated to 7.3 this no longer works. Is this anther apple issue? My wife has an iPad 3, pr

  • Battery life displayed as 0%

    When the button on the battery is pressed it shows 3 green lights but the battery life is still displayed as 0% on my macbook. This is my 3rd battery. The second was given to me while my macbook was under warranty. When this one decided to go out I u

  • My dropbox application won't open and won't sync since I got a new hard drive on my mac book pro - can you help? thanks!

    I was using drop box very well - great - and I've just got a new hard drvie and I think the permissions have changed so I can't even open the application on my desktop.. .and none of hte files are syncing... v annoying as I need to upload some images

  • Cube is still assigned to original system after system copy

    Hello Experts, After system copy (BW and ECC), some cubes are still assigned to the original system. Displaying the flow, the cube is assigned to the new system and the original one and the error message RSAR203 "Source system & (old one) does not ex

  • Wireless Webcam for Surveillance?

    Hello, I am trying to find some recommendations for a good Wireless Webcam that I can use for surveillance in my home. I'd like to be able to move it around, and have it wirelessly take photos and transfer them to my computer / upload them to the web