?
Solved

non static method cannot be referenced from static context

Posted on 2003-03-31
6
Medium Priority
?
504 Views
Last Modified: 2008-02-01
Hi all..

I want to make a Java program which calls (nonstatic) function from another java file, but I always get the error msg :

socket.java:40: non-static method sign(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String) cannot be referenced from a static context
  e.signature = SignatureGen.sign("a", "b", "c", "d",  "e");
                                                                                                      ^

my current program is:

public class socket {
  String signature;
 public static void main(String[] args) {

  socket e = new socket();
  e.signature = SignatureGen.sign("a", "b",  "c",  "d",  "e");
  System.out.println(e.signature);
   
  }
}

The sign class is in SignatureGen.java file, and may not be changed to static..

Anybody can help me? :) thankss..
0
Comment
Question by:pipinana2002
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 2

Accepted Solution

by:
amit_chauhan earned 80 total points
ID: 8243621
It seems sign method is a not a static method.
Change this line :

e.signature = SignatureGen.sign("a", "b",  "c",  "d",  "e");

to

SingatureGen gen = new SingatureGen ();
e.signature = gen.sign("a", "b",  "c",  "d",  "e");


Hope that helps
Thanks
Amit
0
 

Author Comment

by:pipinana2002
ID: 8243649
Hi again..

i change my code already acording to your opinion.. but now there is errors:

socket.java:39: cannot resolve symbol
symbol  : class SignatureGen
location: class socket
  SignatureGen gen = new SignatureGen ();
  ^
socket.java:39: cannot resolve symbol
symbol  : class SignatureGen
location: class socket
  SignatureGen gen = new SignatureGen ();
                         ^

how to correct this probs ya? thankss.. :):)
0
 

Author Comment

by:pipinana2002
ID: 8243676
whoopss.. sorryy.. juz now i mistyped the command :) tks so much for your help :)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:amit_chauhan
ID: 8247702
You welcome.
But you reduced the points !!

Amit
0
 

Author Comment

by:pipinana2002
ID: 8311841
Hi.. i just realize u said that i reduce the points? i just accept your answer.. how come the points reduced ya? i thought that we cannot reduce the points we have entered?

so sorryy.. i really don't know how that can happenn..
0
 
LVL 2

Expert Comment

by:amit_chauhan
ID: 8312094
Dont worry abt it. Even I didnt knew it until I asked this question to the moderators and they gave me some explanation. You basically havent reduced the points, its just displaying the points it will cost for non-members to view this question, something like that crap :)
Check it here :
http://www.experts-exchange.com/Community_Support/Feedback/Q_20570513.html
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question