• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to export the Env Variables in java  RSS feed

 
lakshmipathy Narayan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Using java i opened the .profile and added two variables in that.
In the same code i want to access those variables ,either i've to refresh the .profile or export the variables.When i tried to export the variables using the Runtime,it couldn't execute the command.
Can anyone help me
 
alok subudhi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be specific to your question again so that I can give u a solution. Either u r unable to run the java files or anyrthing else ?
cheers
 
lakshmipathy Narayan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi alok
I got the answer.
I am using Runtime.exec().I tried to use "export" command within that
Runtime.exec("export MONITOR").MONITOR is the variable i added to the .profile before this.
Since export is not associated with shell it couldn't execute the command.
What i have done was,I've written a shell script and within that i called the export.Then i used Runtime.exec("/bin/sh -c myshell.sh").Actually the entire string has to tokenised and stored in an array and then call the array within the exec.
It worked
Anyway thanks alok for ur reply
Pathy
 
George Brown
Ranch Hand
Posts: 919
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doesn't that also render your java code non-portable ?
 
William Barnes
Ranch Hand
Posts: 1049
2
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's portable (to any unix platform you want to run on).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!