Author Topic: Compiling a Java Folder  (Read 5776 times)

0 Members and 1 Guest are viewing this topic.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 5
  • -Receive: 27
  • Posts: 1,524
  • They'll eat you next!
  • Eufloria: Yes
Compiling a Java Folder
« on: November 20, 2011, 01:28:12 AM »
I got this decent Java knowledge, with one thing missing: Compiling...

I know how to compile class files, but entire folders(with subfolders) into jar is another thing.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 23
  • Posts: 930
  • Eufloria: Yes
Re: Compiling a Java Folder
« Reply #1 on: November 20, 2011, 06:05:46 PM »
http://download.oracle.com/javase/tutorial/deployment/jar/build.html

Basically, just type

Code: [Select]
jar cvf YOUR-JAR-NAME-HERE.jar *
into the commandline while you're in the top folder of your class files.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 5
  • -Receive: 27
  • Posts: 1,524
  • They'll eat you next!
  • Eufloria: Yes
Re: Compiling a Java Folder
« Reply #2 on: November 21, 2011, 01:44:04 AM »
I can't make any Jar because it can't find the main class. It says: "Could not find the main class: jar.  Program will exit."

The bat file I execute looks like this:

Code: [Select]

cd bin

path C:\Program Files\Java\jdk1.6.0_25\bin; %path%

echo Main-Class: Game >manifest.txt

java jar cvfm Miner.jar manifest.txt Game.class Core.class ImageCollection.class ImageSource.class Map.class Tile.class TileType.class WindowMananger.class textures

pause


Where Game.class is the main, I also tried to add a manifest, but I'm not quite sure how yet... Completely new to this :P

EDIT: Never mind that, I fixed it in Eclipse, appearantly you can export the project itself :)
« Last Edit: November 21, 2011, 02:19:12 AM by Aino »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 23
  • Posts: 930
  • Eufloria: Yes
Re: Compiling a Java Folder
« Reply #3 on: November 21, 2011, 05:13:58 AM »
I see what your problem is.

Basically, in setting %path% to C:\Program Files\Java\jdk1.6.0_25\bin, you imply that manifest.txt, Game.class, Core.class, etc. are all in the same directory. What I'd have done there is navigate to the folder with Game.class in, then invoked C:\Program Files\Java\jdk1.6.0_25\bin\javac.exe or w/ever the compiler/packager is. I think it's javac.exe, anyway. Always works for me.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 5
  • -Receive: 27
  • Posts: 1,524
  • They'll eat you next!
  • Eufloria: Yes
Re: Compiling a Java Folder
« Reply #4 on: November 21, 2011, 08:11:41 PM »
I'm actually completely new to this, but I found eclipse doing this for you pretty simple, just export it like a jar and put up the mainfile.

But my problem now is that whenever executed, it won't do anything :/

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 23
  • Posts: 930
  • Eufloria: Yes
Re: Compiling a Java Folder
« Reply #5 on: November 22, 2011, 02:16:32 AM »
Yea, I can fix that too. Create a .bat file containing:.

Code: [Select]
@echo off
[b]java[/b] Miner.jar

Doubleclick it.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 5
  • -Receive: 27
  • Posts: 1,524
  • They'll eat you next!
  • Eufloria: Yes
Re: Compiling a Java Folder
« Reply #6 on: November 22, 2011, 02:51:23 PM »
I have fixed it now, don't worry :)

It's executable and runs just fine :)