473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to export a new java version path in perl?

30
Hi, everyone~

I met a problem: the defualt java version on the unix sever is 1.4, but I'd like to export the 1.6 version on the sever (the 1.6 java exists on the sever)

I wrote the code like this in perl:
Expand|Select|Wrap|Line Numbers
  1. system 'export PATH=/usr/java1.6/bin:$PATH';
It works when I just command "export PATH=/usr/java1.6/bin:$PATH" on the shell, but when I run the code I wrote, the sever reposed me:
Expand|Select|Wrap|Line Numbers
  1. sh: PATH=/usr/java1.6/bin:/bin:/usr/bin:/usr/local/bin:/usr/openwin/bin:/usr/bin/X11:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/sbin:/usr/ucb:/usr/sfw/bin:/local/share/bin:.: is not an identifier
Could anyone help me?
Thanks a lot in advance.
Sep 29 '08 #1
10 3782
Icecrack
174 Expert 100+
First please put all code in Code tags,

2nd. try

Expand|Select|Wrap|Line Numbers
  1. system('export PATH=/usr/java1.6/bin:$PATH');
or

Expand|Select|Wrap|Line Numbers
  1. system(`export PATH=/usr/java1.6/bin:$PATH`);
----------------------------------------------------------------------------------------------------------

Expand|Select|Wrap|Line Numbers
  1. PATH=/usr/java1.6/bin:/bin:/usr/bin:/usr/local/bin:/usr/openwin/bin:/usr/bin/X11:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/sbin:/usr/ucb:/usr/sfw/bin:/local/share/bin:.:
this happens because $PATH is a Perl ENV var, its set for the path of perl & you are processing that var. to cancel that in perl you must use single quotes ' or ` or cancel that $ by \$PATH.
Sep 29 '08 #2
anklos
30
First please put all code in Code tags,

2nd. try

Expand|Select|Wrap|Line Numbers
  1. system('export PATH=/usr/java1.6/bin:$PATH');
or

Expand|Select|Wrap|Line Numbers
  1. system(`export PATH=/usr/java1.6/bin:$PATH`);
----------------------------------------------------------------------------------------------------------

Expand|Select|Wrap|Line Numbers
  1. PATH=/usr/java1.6/bin:/bin:/usr/bin:/usr/local/bin:/usr/openwin/bin:/usr/bin/X11:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/sbin:/usr/ucb:/usr/sfw/bin:/local/share/bin:.:
this happens because $PATH is a Perl ENV var, its set for the path of perl & you are processing that var. to cancel that in perl you must use single quotes ' or ` or cancel that $ by \$PATH.
Thanks for your reply, but both of your methods dont work. I know $PATH is a perl env var, and I use quotes ' ', if using quotes " ", I have to write code like \$PATH
Sep 29 '08 #3
Icecrack
174 Expert 100+
Thanks for your reply, but both of your methods dont work. I know $PATH is a perl env var, and I use quotes ' ', if using quotes " ", I have to write code like \$PATH

But have you tried using backtick's thats `System command`

example:

Expand|Select|Wrap|Line Numbers
  1. system(`export PATH=/usr/java1.6/bin:$PATH`);
also what errors are you getting or what output.

try this:

Expand|Select|Wrap|Line Numbers
  1. system(`export PATH=/usr/java1\.6/bin:$PATH`);
Sep 29 '08 #4
anklos
30
But have you tried using backtick's thats `System command`

example:

Expand|Select|Wrap|Line Numbers
  1. system(`export PATH=/usr/java1.6/bin:$PATH`);
also what errors are you getting or what output.

try this:

Expand|Select|Wrap|Line Numbers
  1. system(`export PATH=/usr/java1\.6/bin:$PATH`);
No, they dont work. I also have another question, if my current directory is /mount/autofs/home_mbc/sniu, and I run code like this:

Expand|Select|Wrap|Line Numbers
  1. system 'cd myperl';
it will repoonse and print out "/mount/autofs/home_mbc/sniu/myperl", but the directory wont change to /mount/autofs/home_mbc/sniu/myperl, it is still /mount/autofs/home_mbc/sniu
Sep 30 '08 #5
Icecrack
174 Expert 100+
No, they dont work. I also have another question, if my current directory is /mount/autofs/home_mbc/sniu, and I run code like this:

Expand|Select|Wrap|Line Numbers
  1. system 'cd myperl';
it will repoonse and print out "/mount/autofs/home_mbc/sniu/myperl", but the directory wont change to /mount/autofs/home_mbc/sniu/myperl, it is still /mount/autofs/home_mbc/sniu
also you are using the wrong format for system command its better to use

Expand|Select|Wrap|Line Numbers
  1. system(`cd myperl`) || die "$!";
it depends on the user that your running perl on, does it have access to myperl?

also are you running perl via CGI or just in CLI ?
Sep 30 '08 #6
KevinADC
4,059 Expert 2GB
No, they dont work. I also have another question, if my current directory is /mount/autofs/home_mbc/sniu, and I run code like this:

Expand|Select|Wrap|Line Numbers
  1. system 'cd myperl';
it will repoonse and print out "/mount/autofs/home_mbc/sniu/myperl", but the directory wont change to /mount/autofs/home_mbc/sniu/myperl, it is still /mount/autofs/home_mbc/sniu
that will cd in the shell, not in your perl script. Use the chdir() function.
Sep 30 '08 #7
Icecrack
174 Expert 100+
that will cd in the shell, not in your perl script. Use the chdir() function.
Kevin is right, i'm not awake today,

also what are you trying to do?

this will help us more, i know you want to set the path for java but the second topic

Expand|Select|Wrap|Line Numbers
  1. system 'cd myperl';
Sep 30 '08 #8
anklos
30
that will cd in the shell, not in your perl script. Use the chdir() function.
I see! Thank you !
Is that also the same reason that I cant export java version? Because the command is for shell, not for perl script?
Sep 30 '08 #9
KevinADC
4,059 Expert 2GB
I see! Thank you !
Is that also the same reason that I cant export java version? Because the command is for shell, not for perl script?
I believe so. You may want to look at the %ENV variables if you need to add something to perls path environment at run time.

Expand|Select|Wrap|Line Numbers
  1. $ENV{'PATH'} .= ';/usr/java1.6/bin';
Sep 30 '08 #10
anklos
30
I believe so. You may want to look at the %ENV variables if you need to add something to perls path environment at run time.

Expand|Select|Wrap|Line Numbers
  1. $ENV{'PATH'} .= ';/usr/java1.6/bin';
Thanks for your help!
Oct 1 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Lionel | last post by:
Hi all, I would like having more informations on how we could exchange informations and/or objects between PERL and JAVA. We have a Java programs that open, maintain and close telnet...
6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
4
by: Jean-François Blais | last post by:
Many must have asked that question. I intend to write a few programs which will be CPU intensive. I know a little of Java. Would a language that yields native code, instead of bytecode perfrom much...
34
by: Anthony Irwin | last post by:
Hi All, I am currently trying to decide between using python or java and have a few quick questions about python that you may be able to help with. #1 Does python have something like javas...
2
by: Janna | last post by:
I have the Java JVM installes on my server. I uncommented extension=php_java.dll in php.ini I uncommented and proerpyl filled out the section in php.ini: java.class.path...
1
by: aapexclient | last post by:
I have a problem with Java finding my custom class directory. I have searched the forums and tried everything, but nothing seems to work. The <javapgm>.java compiled cleanly and created...
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.