Eric Mission

Greenhorn
+ Follow
since Apr 22, 2009
VA
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Eric Mission

Let's assume I need to develop only one function, that will be implemented to some system.
For this I do not need a class, just a function with input parameters and return parameter.



All methods/functions have to sit inside something- hence a class file. If you don't need to instantiate an object then make the method static.

I could create a class then in code fill arrays aString1, aString2 and aString3 with data then pass them to my function.


Sounds like your making too much work for yourself though. Why not have 1 function that accepts a list of arrays?


Now, you can have as many arrays as you want passed in to a single method.

Is it possible to facilitate my testing with some Eclipse tool?


Try JUnit for unit testing.
10 years ago
I've been a JSE developer for about 7 years now- writing applications ranging from serial communications on Unix boxes to JDBC and AWT on Win boxes. In the 7 years I've learned a lot about architecture and design... what works and what to avoid in order to reduce time, cost and effort for deployments.

I've recently taken up trying to learn JEE by reading books (HeadFirst series and the like), doing online tutorials, and even searching through forums like this one for information. I started with learning EJB 2.1 and then moved on to EJB 3.0 and finally to EJB 3.1. Sticking with JEE5 and just browsing through JEE6.

During the course of searching and learning I have discovered 1 thing about the JEE standard that seems to escape me. When should an object be declared an EJB and when should it not? The major difference, that I've found, between JSE and JEE is the introduction of EJBs. And it is this additional component that really confuses me. Should my logging be an EJB or should it just be a regular POJO that is called from a JSP page? Should my LDAP lookup into Active Directory be an EJB or should it be a regular POJO?

Hopefully, I have stated this correctly. I feel that the majority of answers will be- depends. Depends on design needs, user needs, and architecture. More often than not, that answer has the ability to confuse a question further than what is intended. What I am looking for, is more of an answer that states... "A Java class should be an EJB if it needs this and that" OR "A Java class should be a POJO if it doesn't need this and that".

Any thoughts?
Archana, I've never used the SshWrapper class before so I can't comment on the error you are having but I am curious as to why you don't just use an SSH client. There are several freely available ones out there. I personally use PuTTy which has telnet, ssh and more.

I did some searching on this class and found a link to the SOURCE. I noticed that the class is using a basic socket to connect. As I mentioned before I'm not familiar with the API other than just reading the source but to me that generic socket connection may be your problem if it isn't taking permission into account. If the SshWrapper class does not account for permissions on the machine you are trying to access then that may explain why you are getting NULL when you send a command. In other words, the Unix machine may permit you to do a remote SSH connection but may forbid you from changing directories or running other commands.

I am guessing that you want to just issue a



or a



to the server and you can't even change directories (remote access permission block?).


My recommendations: 1) I would try to create my own custom socket server/client application that would read the files or even transfer them locally for reading 2) use an SSH client.

Hope that helps.
The Java I/O API has top-level objects- Reader and Writer which both have some useful methods to inherited classes like BufferedReader or BufferedWriter.

From the Java I/O Streams-

Some other notable methods in the top-level classes include skip(int), mark(int), reset(), available(), ready() and flush(), these are described below...

...The flush() method simply writes out any buffered characters (or bytes) to the destination (for example, file, or socket).




Closing any type of I/O stream (file or socket) is a good habit to follow for several reasons- freeing up system resources, freeing up the heap for other objects, preventing file locks for other applications or for multi-threaded applications and so many more reasons.
11 years ago
I found this piece of code in a posting...



and tried it but it didn't change the socket connection (I did create my own SSLSocketFactory similar to this posting). Though it does seem to be promising. Is anyone familiar with this setting?
Does anyone know if it is possible to perform a JNDI lookup on Weblogic using a custom SSL socket connection other than the built-in connection method?

For example:




I thought there might be some class that I can extend from and add to the code or some other setting that I can make to force the use of a different socket object but I can't find any documentation anywhere on it. Which makes me believe that it isn't possible but I wanted to ask the community anyway.

Some additional info...
Clustered server with an Alteon load balancer and 3 Weblogic 9.2 MP3 instances in the cluster (round robin) running a Web site.
An internal (tier3) support tool trying to connect to the load balancer to get info on the cluster only works when connecting directly to an instance in the cluster. As well as when connecting to the load balancer with a custom socket connection. The Alteon does not filter protocol (t3s) or IPs so the idea is to use the custom socket connection in conjunction with a jndi lookup to hit the load balancer directly. The result of using the default connection methods going directly to the load balancer is a timeout. I don't recall the error off-hand but it happens after the handshaking, I would have to get back with the error message. I don't feel this is worth troubleshooting unless someone is curious about the error.

Thanks for the answers!
I agree with Janeice, I would have made an abstract or concrete class that contains the getters and setters, followed by child classes that would extend from that. Then in my tester class I would create an object that simply calls those methods.

You have too many concepts going on in one class and it becomes confusing. You could do all of this with only 1 (one) for loop.

For example-






Hopefully that will help some. This is the basic concept of OO programming and is extremely powerful in helping a computer scientist in solving real world problems.
12 years ago
Ooppss, sry Joanne! This rotten connection is so sloooow (didn't see your post) I might as well have mailed in my post-
13 years ago
Your have several problems with this code...

1 You don't adhere to Sun's naming recommendations.

Sun Naming Conventions

2. Read this article to understand pass-by-value and pass-by-reference for Java.

Java parameter passing

The third issue is a result of trying to manipulate the parameter instead of capturing the return value from your method. NumbertoGuess returns a value- and you aren't storing it into anything!

13 years ago

By the way: it#s not LOOPA but LOOPA:


Ah! yes it is- Some days I wish forums had compilers built into them so banging out small examples like that could be syntax checked Alas, I would also like to win the lottery...

even your labelled "break" is unnecessary



So very true, though I figured that if someone was posting a question about a GOTO statement in OOP I thought that by presenting the most basic of basic programming methods I could think of may shine some light for him/her, though probably a mute attempt. Not to mention providing an example of using a label as James suggested.
13 years ago
Sounds like your method has a logic error if you are trying to use GOTO.

Post your code.

Try using a combination of If Else, Switch, For loop and additional method calls to handle logic.

GOTO explained

13 years ago
I have run into build issues with large projects before using Eclipse/NetBeans/BlueJ whatever... To get around this, I generally try to section out processes into different projects or packages, then turn off auto-build (in Eclipse world) and compile each as needed. I find this an easier way of developing because then I can just reference to the projects or built libraries in dependent projects.

Sometimes splitting classes into packages or other projects isn't feasible when given code... this is when Java's command line utilities "javac" and "jar" are so extremely useful. Using the -d option with "javac" to place the compiled classes into another directory and then using the "jar" command to jar those classes makes refactoring complex pre-architectured projects simpler. All that is needed then to move class files is to drag and drop from within the directory structure or TextPad/NotePad/VIM to copy and paste code.

Hope that helps
13 years ago
simple, you can't so, you don't. That isn't an issue when following the javabean convention...

13 years ago
There are several problems with your code- the first being that you nested a method inside a method.



If I was going to pass something to you I would do 2 things- 1. call you to tell you 2. pass it




Try Sun's tutorial's Java for beginners
13 years ago