Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Passing several files to another java program.

  1. #1
    Junior Member
    Join Date
    Feb 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Passing several files to another java program.

    Alright, so what I'm wondering is: What would be the best way to take a directory filled with files and pass them to another file? All of the files are ".java source code files"

    What I'm trying to do is take a directory filled with these files & write a process that passes each file in the list through JD-CLI & saves the decompiled source file to a destination directory.

    Decompiling this list of classes is taking forever because I have to do it one by one, thanks to CLI not granting us the ability I'm trying to write. Keep in mind I am starting this process from scratch! Thanks guys!

  2. #2
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    284
    My Mood
    Cool
    Thanks
    0
    Thanked 38 Times in 36 Posts

    Default Re: Passing several files to another java program.

    Rather than use Java I would do this with something like a shell script, an Ant file, or some other platform that is typically used to run external applications on files.

    Regards,
    Jim

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Passing several files to another java program.

    The File class has a method to return a list of files in a directory.
    The Runtime class has a method that will execute a command-line built in the program.

    Are those the capabilities you need?
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    Feb 2019
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Passing several files to another java program.

    file is one of them I need; with runtime() would I be able to process the list of files obtained from the file function through jd-cli.jar?

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Passing several files to another java program.

    with runtime() would I be able to process the list of files
    The Runtime class has a method that will execute a commandline. Do you have a command that can be executed from a commandline that will do what you want?
    Open a DOS window and execute a command to see if it does what you want. That command can then be executed in the Runtime class's method.

    through jd-cli.jar
    If the program you want to execute is a java program contained in a jar file and it can execute in the same JVM as the driver program, then you can call its main method directly without using the Runtime class's method.
    There would be a problem that would need special handling if the called program uses the System.exit() method.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Re: Java program which can list all files in a given directory
    By Dinesh Raja in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 5th, 2013, 09:27 AM
  2. how to link html files to java program
    By Mumpy Zinu in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 18th, 2013, 10:52 AM
  3. Help fixing my Java program! Reading files
    By Spanky_10 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 27th, 2013, 05:51 PM
  4. How can I read txt files in java program??
    By sakura_smile in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 9th, 2012, 06:18 PM
  5. java program check for files
    By Creeper in forum Java Theory & Questions
    Replies: 2
    Last Post: February 29th, 2012, 02:38 PM