NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

trying to run my java code

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Fatimah



Joined: 28 Nov 2011
Posts: 3

PostPosted: Mon Nov 28, 2011 9:07 am    Post subject: trying to run my java code Reply with quote

good day all,
I am trying to run my java code and it works only in my pc.
if I try to run it in different pc using the jar file it won't work!!

can any one help me please???
Back to top
lvskiprof



Joined: 19 Jul 2011
Posts: 49
Location: Las Vegas, NV

PostPosted: Mon Nov 28, 2011 7:07 pm    Post subject: Re: trying to run my java code Reply with quote

How are you trying to run it on the other system? What error are you seeing?

You probably need to set up you CLASSPATH environment variable so that the required libraries are there for Java to find.

By default Netbeans copies all dependent libraries into a lib directory under the dist directory where it places your jar file. The MANIFEST file it creates tells it to look for dependent jar files in a lib directory under the directory you run it from. Adding the lib file to your jar should work, or creating a lib directory under where you run the jar from with all the required jar files in it, will also work.

I have been using the last option for my Selenium programs, because adding the lib directory to every jar file just means I have the same files copied into every Selenium test program I write.

Mike

Fatimah wrote:
good day all,
I am trying to run my java code and it works only in my pc.
if I try to run it in different pc using the jar file it won't work!!

can any one help me please???
Back to top
Fatimah



Joined: 28 Nov 2011
Posts: 3

PostPosted: Mon Nov 28, 2011 11:22 pm    Post subject: Re: trying to run my java code Reply with quote

I took the dist folder as it is containing the jar file and the lib folder.
I did not receive any kind of errors but the button that works well in my system stop working in other systems.

specifically this button using a class I wrote by my self.
other buttons working well (cancel --> close the window and ends the execution -browse--> navigates the files and folders)




lvskiprof wrote:
How are you trying to run it on the other system? What error are you seeing?

You probably need to set up you CLASSPATH environment variable so that the required libraries are there for Java to find.

By default Netbeans copies all dependent libraries into a lib directory under the dist directory where it places your jar file. The MANIFEST file it creates tells it to look for dependent jar files in a lib directory under the directory you run it from. Adding the lib file to your jar should work, or creating a lib directory under where you run the jar from with all the required jar files in it, will also work.

I have been using the last option for my Selenium programs, because adding the lib directory to every jar file just means I have the same files copied into every Selenium test program I write.

Mike

Fatimah wrote:
good day all,
I am trying to run my java code and it works only in my pc.
if I try to run it in different pc using the jar file it won't work!!

can any one help me please???
Back to top
lvskiprof



Joined: 19 Jul 2011
Posts: 49
Location: Las Vegas, NV

PostPosted: Tue Nov 29, 2011 6:01 pm    Post subject: Re: trying to run my java code Reply with quote

I am going to assume that you see the jar file for your class in the lib subdirectory. But check to see if the jar files in the lib subdirectory for that class are also in there, in case it has some dependencies that did not get copied into the lib directory for your project.

The other possibility that I can think of would be that this other system might not have some library installed on it that you have on your development system.

But all those cases would generate an exception saying that a class couldn't be found. If you are not seeing that error then something else is going on, in which case you will probably have to do some debugging on the system where it is failing to run properly.

Mike

Fatimah wrote:
I took the dist folder as it is containing the jar file and the lib folder.
I did not receive any kind of errors but the button that works well in my system stop working in other systems.

specifically this button using a class I wrote by my self.
other buttons working well (cancel --> close the window and ends the execution -browse--> navigates the files and folders)
Back to top
Fatimah



Joined: 28 Nov 2011
Posts: 3

PostPosted: Fri Dec 02, 2011 1:13 pm    Post subject: Reply with quote

is it matter if I use win 7 and try to run the code in vista ????!!

couz now I am receiving this message

"could not find the main class. program will exit."
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo