LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-12-2010, 03:16 PM   #1
rickrvo
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Rep: Reputation: 0
Java non-static variable cannot be referenced from a static context issue


Hi,

I'm having some problems on the line with ***. This is from a OpenEntidade.java class file and I'm trying to update EmprestadorView's variables. Does anyone know how to fix this?


EmprestadorView.java
-------------------
public class EmprestadorView extends FrameView {
...


OpenEntidade.java
-----------------
public class OpenEntidade extends javax.swing.JFrame {
...

private void jFileChooser1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
File fix=jFileChooser1.getSelectedFile();

String aux1=null;
try {
BufferedReader inputStream = new BufferedReader(new FileReader(fix));

String tmp=null;
while ((aux1 = inputStream.readLine()) != null) {
tmp=aux1.substring(0, 6);
if(tmp.compareTo("Nome: ")==0){
aux1=aux1.substring(6);
EmprestadorView.emp[EmprestadorView.total_emp].setNome(aux1); ***
}
tmp=aux1.substring(0, 11);
if(tmp.compareTo("Emprestei: ")==0){
aux1=aux1.substring(11);
EmprestadorView.emp[EmprestadorView.total_emp].setEmpout(aux1); ***
EmprestadorView.setEmpIn(aux1); ***
 
Old 02-12-2010, 04:05 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 59
Well its hard to tell you the exact problem without the exact (i.e. complete) code. Its telling you that you're trying to use a variable as static, but its not declared static. Make sure that "EmprestadorView.emp" is declared "static". However, it might also (or either) be that "EmprestadorView.total_emp" must be static but isnt declared static.

Are there accessor methods (getter/setter) that you should be using instead?
 
Old 02-12-2010, 04:26 PM   #3
rickrvo
LQ Newbie
 
Registered: Feb 2010
Posts: 2

Original Poster
Rep: Reputation: 0
thanks! staticed the emp and good to go
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java: non-static variable this cannot be referenced from a static context chief_officer Programming 4 05-29-2006 02:37 PM
C++: difference between static method variable and static class variable? Thinking Programming 3 01-16-2006 11:08 AM
extern static variable alaios Programming 9 09-11-2005 05:11 AM
What is a static variable? saiz66 Programming 7 09-30-2004 06:17 PM
FC2 Overriding static if in favor of dhcp system set for static pkraus109 Linux - Networking 8 09-21-2004 12:13 PM


All times are GMT -5. The time now is 06:42 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration