Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8464049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:37:27+00:00 2026-06-10T14:37:27+00:00

Im trying to compile some java files using the Runtime.getRuntime.exec(command) and im generating the

  • 0

Im trying to compile some java files using the Runtime.getRuntime.exec(command) and im generating the command. The code below shows what i am doing:

String command = "javac ";
    for(String s: this.getPackages())
    {
        command = command + "/home/benuni/CompileFiles/" + project + "/" + s + "/*.java ";
    }

    try {
        System.out.println("command: '"+ command +"'");
        Process pro = Runtime.getRuntime().exec(command);
         printLines(" stderr:", pro.getErrorStream());

        pro.waitFor();

This is giving the following output:

command: 'javac /home/benuni/CompileFiles/HelloWorldProject/HelloWorldPackage/*.java '
stderr: javac: file not found:     /home/benuni/CompileFiles/HelloWorldProject/HelloWorldPackage/*.java
 stderr: Usage: javac <options> <source files>
 stderr: use -help for a list of possible options

and its not working.. but if i copy the command into my shell, it works no problem… any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:37:29+00:00Added an answer on June 10, 2026 at 2:37 pm

    Java doesn’t expand the * wildcard for you. That’s a facility of the shell. Instead, you’ll need to list the directory to get all of the contained files.

    Something like this would do the trick to build up your command:

        File[] files = new File("/home/benuni/CompileFiles/" + project + "/" + s).listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".java");
            }
        });
    
        StringBuilder command = new StringBuilder("javac");
        for(File file : files) {
            command.append(" ").append(file.getAbsolutePath());
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to compile some Clojure code to Java using the Clojure 1.2
I'm trying to compile some fortran files in Xcode, using a makefile made by
I'm trying to compile some java (learning java currently), and to do so I
I'm trying to compile some code which contains the following declaration, because I would
I'm currently trying to compile some code examples from http://developer.gnome.org/gtkmm-tutorial/unstable/sec-treeview-examples.html.en but from what I
I am using VC2010, trying to compile some library written in C99 for Linux.
I'm trying to compile with g++ some code previously developed under Visual C++ 2008
I'm trying to follow the steps to compile some C code to import into
I am trying to compile a code that has a include directory with some
I'm trying to inject some Scala code into my existing Java app. (So, being

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.