1

I am working on a program that essentially generates another java program. The program generates some folders, a java class, and then a Batch file to compile the newly generated program.

Here is the layout of how stuff is generated

Root folder (PluginGenerator in my case)
  PluginGenerator (Program which creates the new program)
  Bukkit.jar (Compiled with new classes)
  Compiler.bat (gets created when new program is generated)
  data.txt (not used)

  New project/program folder (HelloPlugin in my case)
    data folder
      plugin.yml (to be compressed into jar)
        com
          package
            generated class file (HelloPlugin in my case)
    output folder (.jar file needs to be created here)

So once the Hello class has been generated a batch file geets made in the root folder. The batch file needs to compile HelloPlugin.java into a class file and put the package (com.pack) into a jar along with plugin.yml.

The location of the rootfolder cotaining everything is found in my java program and is used to write the correct directories in the batch file.

I know i can compile files with the built in JavaCompile, but I want to do it this way for fun.

Everything works except the batch file. The class gets compiled but the jar it creates only contains the META-INF folder with the manifest, but not the plugin.yml or package containing the class.

I don't have mauch experienve with batch or compiling with CommandPrompt so i'm not sure why it isn't working.

Here is the Batch file that gets generated

@echo off
javac -cp C:/Users/Aiden/Desktop/PluginGenerator/Bukkit.jar C:/Users/Aiden/Desktop/PluginGenerator/HelloPlugin/data/com/pack/HelloPlugin.java
jar cf C:/Users/Aiden/Desktop/PluginGenerator/HelloPlugin/output/HelloPlugin.jar C:/Users/Aiden/Desktop/PluginGenerator/HelloPlugin/data/plugin.yml C:/Users/Aiden/Desktop/PluginGenerator/HelloPlugin/data/com
pause

EDIT I think it I may have packed the whole of my C drive into the jar. Although that would take a long to to compress into the jar, so thats not exactly want has happened.

Anyway he is a picture of what the jar contains.

http://tinypic.com/r/i6frcj/8

3
  • so this question is basically not compiling related, but just about how to use "jar" command? jar only packages stuff into .jar (which is really a .zip), it doesn't compile anything. Have you tried to use jar command outside your batch file? do you see the same issue? Commented Mar 13, 2014 at 11:49
  • @eris Thanks for the response. I fixed it but using "cd C:/Users/Aiden/Desktop/PluginGenerator/HelloPlugin/data/" before the jar command. I then changed the jar command to something like "jar cf C:/something/somethingelse/output/HelloPlugin.jar plugin.yml com". Commented Mar 13, 2014 at 14:41
  • Ok. You should add it as an answer and accept that. Commented Mar 13, 2014 at 18:35

1 Answer 1

1

I fixed it but using "cd C:/Users/Aiden/Desktop/PluginGenerator/HelloPlugin/data/" before the jar command. I then changed the jar command to something like "jar cf C:/something/somethingelse/output/HelloPlugin.jar plugin.yml com".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.