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

  • Home
  • SEARCH
  • 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 8130975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:55:43+00:00 2026-06-06T08:55:43+00:00

Hello everyone don’t know why this code works on windows but not on linux

  • 0

Hello everyone don’t know why this code works on windows but not on linux so if anyone sees something wrong with this or another way of doing this I would really appreciate some guidance thanks for your time.

Process p = Runtime.getRuntime().exec(linuxCommand);
int cont=0,retorno=p.waitFor();
try {
     synchronized (this) {
     while (retorno!=0 && conteo<10000){
         retorno=p.waitFor();
         System.out.println("cont++);
     }
    if (retorno == 0) {
        ans = true;
        logger.info("Return Value: " + ans);
    }else{
        ans = false;
        logger.info("Return Value: " + ans);
    }
 }

} catch (InterruptedException e) {
    e.printStackTrace();
}

Objective: create *1_Output.txt* from the info contained in *1_Input.txt*,

MyObjectT resides in /var/xp/client/a/h/n/test
MyObjectT will call several classes in /var/xp/client/a/h/n/clases/z1, and eventually READ the content of 1_Output.txt so it can return ans(true/false)

PROBLEM

  • on windows: the flow when to fast it did not wait for the 1_Output.txt file to be created so there was nothing to read, with current code that was solved. (p.waitFor() eventually return 0 and everyone is happy)
  • Linux : p.waitFor() never returns 0 the flow ends and nothing

linuxCommand is a parsed String that represent a java command to be executed in linux

notice that if I paste this command as it is in the command shell it would run ok with no warning or error . I donw think “ play an important role here. linuxCommand->
/opt/jdk/jdk1.6.0_22/bin/java -classpath “/var/xp/client/a/h/n/clases/z1″:”/var/xp/client/a/h/n/test” MyObjectT /m:Param21 /f:”/var/xp/client/a/h/n/IOFile/1_Input.txt” /o:”/var/xp/client/a/h/n/IOFile/1_Output.txt”

so what confuses me is that if use getErrorStream() to track down some errors an I get this

Exception in thread "main" java.lang.NoClassDefFoundError: MyObjectT 
Caused by: java.lang.ClassNotFoundException: MyObjectT 
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: MyObjectT.  Program will exit.

any help, its much appreciated thank again

lol Im sorry for the variable name in spanish retorno=return but at the time I translated I did not stop and think about the return ajajjaajajajaj :=)

  • 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-06T08:55:45+00:00Added an answer on June 6, 2026 at 8:55 am

    There’s a few things in play, simultaneously. First, you’ve got multiple programs running — this one and the one that you’re spawning — and the errors in that program are causing troubles here.

    First, the linuxCommand:

    /opt/jdk/jdk1.6.0_22/bin/java -classpath
    "/var/xp/client/a/h/n/clases/z1":"/var/xp/client/a/h/n/test"
    MyObjectT /m:Param21 /f:"/var/xp/client/a/h/n/IOFile/1_Input.txt"
    /o:"/var/xp/client/a/h/n/IOFile/1_Output.txt"
    

    I’ve arbitrarily line-wrapped it. Depending upon how you’ve defined this string in your program, you may need to escape all those " marks in this string. (If you just print this using System.out.println(), what does it look like?)

    Probably the better approach is to use a slightly different form of exec(), one that takes an array of strings instead of a single string. This way you can break the parameters as the program requires without worrying about proper shell quoting. It’d look something like this (untested) chunk:

    String linuxCommand[] = {"/opt/jdk/jdk1.6.0_22/bin/java",
                             "-classpath",
                             "/var/xp/client/a/h/n/clases/z1:/var/xp/client/a/h/n/test",
                             "MyObjectT",
                             "/m:Param21",
                             "/f:/var/xp/client/a/h/n/IOFile/1_Input.txt",
                             "/o:/var/xp/client/a/h/n/IOFile/1_Output.txt"};
    Process p = Runtime.getRuntime().exec(linuxCommand);
    

    You did say you’ve run this command by hand in a shell to confirm it works, but those /i, /o, etc. feel very awkward on a Unix-alike platform. Are you confident that format works as expected on Linux?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello everyone I'm working with Eclipse under Windows XP, but I can't find there
hello everyone i have a problem with my 3-tiers application i don't know how
hello everyone I have this snippet of the code: local fun NTimesF(f, n:int) =
Hello everyone please help me out regarding this this piece of code $user =
hello everyone I found this function in Kernel of the Linux: inline task_t *context_switch(task_t
Hello everyone i need to convert this code to a function with 2 parameters
Hello everyone I am trying to resize an image of 700kb with imagecreatefromjpeg. This
Hello everyone I'm currently having 2 issues with the code below: Upon return of
Hello everyone I'm trying to work with jboss messaging, does anyone knows the default
Hello everyone i currently have this: import feedparser d = feedparser.parse('http://store.steampowered.com/feeds/news.xml') for i in

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.