Ok, got it. I found out the reason I wasn't getting a .class file was because it was getting an error when compiling I was overlooking, and I just moved my Picture.class file into the same directory and it worked just fine. Then I created a new project, imported sources and classes, selected Main class, and compiled just fine. I was running into a little problem for a bit while trying to make the .jar, but that was just because I hadn't compiled it as a Project yet, so once I did that, it worked just fine. Now that I have a .jar, when I try to run it, it doesn't seem to do anything. I need it to input RGB values from 0-255, and the directory of a picture. When running it in the compiler, I just used nextInt() or just next() to input the values for the RGB color, and for the directory for the picture. Do I need to set up some sort of GUI for it now that I'm trying to run it as a standalone program?
naw, but it probably would make life easier for your brother...
At this point, I can't find out any way to take any sort of input while it's a .jar, or return an output.

What I need is 3 inputs for the RGB values for a pixel's color, then 1 more input for the directory of the picture it's going to check said colors against, and lastly to output all the coordinates found.

Suggestions? I can't seem to find any explanation of how to do this from a search on google, either.
I don't think it should matter if it's a jar file or separate class files (as someone else already mentioned, a jar file is just a compressed collection of class files). When I have a jar file, I run it on the command line like this:

Code:
java -jar blah.jar

And that should run just like

Code:
java blah.class
would. You can put any additional arguments at the end of those command lines, and they'll get passed to the program.
Just got it working. I remembered a .bat file I had to use when starting up my Minecraft server, when it used to be on my desktop, and basically used that in place, except replacing the craftbukkit server.jar file with my own RGBSearch.jar.

Here's the RGBSearch.bat file I used to run it:
Code:
@ECHO OFF
SET BINDIR=%~dp0
CD /D "%BINDIR%"
"%ProgramFiles(x86)%\Java\jre6\bin\java.exe" -Xincgc -Xmx1G -jar RGBSearch.jar
PAUSE


After getting that to work, we found out that the command window it runs in has a limit of lines it will display, later found to be 300 lines. So I added a display counter, set the limit to 298 (left two for space so it can output that the output was overfilled, and was waiting for user input) and now it works perfectly.

Thanks for the help, everyone.
The Windows command prompt window does have a 300 line buffer by default. I like to increase it to a thousand or more when I have to use cmd.exe, though I use Cygwin with mintty as the terminal when possible because the Windows terminal sucks so badly.

What are you doing with so much output? If you're saving it to a file, it's a lot easier to redirect the output to a file than to add a pager in your program's output. Here's how easy that is:
Code:
run.bat >file.txt
There is a "jar.exe" utility for this; but there is an easier way which is INCREDIBLY simple:

Make a folder called "META-INF". Inside that folder, make a file called "MANIFEST.MF" (you can just open NotePad and save it as that, with the file type set to "All *.*"). Inside that file, type the following (replace "Foo" with the name of your main class, and do not include the ".class" extention):

Manifest-Version: 1.2
Main-Class: Foo
Created-By: Your Name

Put the META-INF folder and your class files into a zip file, and change the name from "foo.zip" to "foo.jar". LIKE MAGIC, you can just double click the jar file and it will RUN (on most computers ... otherwise you have to change your computer settings to run ".jar" files with "java", and it needs the "-jar" tag. For example, from the command prompt you'd type "java -jar foo.jar" to run it).

You can also put your source files in there as well, along with other resources (such as images), so that everything is in one nice little package. The trick to opening files from the jar file (so that they do not have to be external) is to do this in your code:

NameOfTheCurrentClass.class.getResource("fileName");

That gives you a URI (I think), but can be used with some things, e.g. new ImageIcon(YourClass.class.getResource("IMAGE.GIF"));

You can put some of the resources in folders in the jar file, in which case you'd use "." or "/" (I forget which) in the MANIFEST file and getResource method to designate folders (e.g. I put the source in a "src" folder when there are a lot of files). You can still open jar files using archive utils, or just change it back to a zip temporarily as needed.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement