This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!

Mike Cutter

Ranch Hand
+ Follow
since Jun 09, 2002
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 Mike Cutter

I tried the following code:



I get the following compilation errors:

non-static variable x cannot be referenced from a static context
x.a2();
non-static variable z cannot be referenced from a static context
z.a2();
non-static variable z cannot be referenced from a static context
z.a1();
non-static variable x cannot be referenced from a static context
x.a1();

I'll admit I am pretty lost on why the syntax is wrong and the logic is not making sense.
9 years ago
I put the x.a2(); in the main() method.

I now get this error:

non-static variable this cannot be referenced from a static context
9 years ago
I am taking a Java class and we are covering polymorphism.

I have to utilize the given code in my assignment:


I put all this into one big public class. When I complied it, I get the following error:

<identifier> expected
x.a2();

How do I get this polymorphic method call x.a2(); to compile without errors?

Thanks,

Mike

9 years ago
In the following code:



Do the six modifiers satisfy the following requirements?

1. It must be possible to create instances of Alpha and Beta from outside the packages in which they are defined.
2. When an object of type Alpha (or any potential subclass of Alpha) has been created, the instance variable alpha may never be changed.
3. The value of the instance variable alpha must always be "A" for objects of type Alpha.

The above code was the only combination of private, protected, and public modifiers that I can get compiled. By using the public modifier, I was unsure if the code satisfied the requirements?

Any insight would be helpful.

Thanks,

Mike
13 years ago
My company purchased this product called the Versata Logic Server. Its manual says that its logging is based on Sun's java.util.logging package.

The logging is set to the default of the WARNING level, 1 log file, and about 1 MB in size.

I want to have the log file reach 3 MB in size and keep the 10 previous log files. When the log file reaches 3 MB in size, it copies it and starts a new log file.

I am not too familiar with the Java Logging API. Any suggestions would help me.

Thanks,

Mike
13 years ago
I am using a 3rd party ganymed-ssh2-build208.jar Secure Shell library file to obtain the df output from UNIX systems.

I extracted all the classes from the ganymed-ssh-build208.jar file. I then created a new jar file which contains the class files from my source code and the Secure Shell class files. Now this is a huge jar file. This resolved the Secure Shell references not being found.

If I properly put the .java.policy file in the home directory of each user on each system accessing using a web browser, the applet loads just fine. If there is no .java.policy file, I get AccessControlException errors. This will become problem because there is no possible way I am going to be able to copy the .java.policy in each and every home directory.

Is there a way to package the .java.policy security file into the jar file, so anybody can access the applet? Is there an alternative method that can circumvent the security issues with an applet other than the .java.policy file?

Mike
14 years ago
This is what is the Exception in the Java Console.

Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: ch/ethz/ssh2/Connection
at DF.actionPerformed(DF.java:115)
at java.awt.Button.processActionEvent(Unknown Source)
at java.awt.Button.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

In order to connect to each UNIX client to run the "df" command, I use Secure Shell with the ganymed-ssh2-build208.jar which is where the Connection class is being referenced from.

I used this command and the applet worked:
appletviewer -J-Djava.security.policy=java.policy DF.html

This is the .java.policy file:
grant {
permission java.security.AllPermission;
};

This is the HTML file:
<applet CODE="DF.class" ARCHIVE="DF.jar,ganymed-ssh2-build208.jar" WIDTH=600 HEIGHT=750></applet>

In the Mozilla web browser with this URL accessing the local file, the applet worked:
file:///DFapp/DF.html

mcdunix is my web server's hostname. The applet is not working here.
http://mcdunix/DFapp/DF.html
14 years ago
I created an applet that utilizes the UNIX df command. I have a Choice where each UNIX hostname is listed. I have a Button that when clicked goes out an retrieves the output of the df command and puts into a TextArea.

With appletviewer, the applet works fine after I put the ".java.policy" file with "java.security.AllPermission" in the home directory. On Windows XP with Netscape and Internet Explorer, the applet works fine when I load the applet HTML file into the browser. Also on my IBM AIX system with Mozilla, the applet works fine when I load the applet HTML file into the browser.

On my IBM AIX system, I am using IBM HTTP Server which is using an Apache web server. From the URL of the web server, the applet is loaded, but nothing appears in the TextArea after clicking the Button. I have tried on Windows XP, AIX, Netscape, Internet Explorer, and Mozilla. The browser just has the message at the bottom "Applet DF started".

Can anyone give any ideas why the applet puts the df command in the TextArea as a local file, but not through the web server?

Thanks,

Mike Cutter
14 years ago
Has anyone had experience programming interfaces with the JNDI for Network Information Service (NIS), formerly known as Yellow Pages (yp), in the UNIX operating environments?

Are there any sites with some Java coding examples for NIS user administration like changing passwords and adding and deleting users?

Thanks,

Mike Cutter
How do you capture UNIX commands that produce only output into a TextArea? Say, I want to display the results of the UNIX "df" or "who" command into the TextArea. I know that I would have to somehow take the results and input it into a Stream, convert the Stream into a String, and display the String in the TextArea.

I know how to take a file like /etc/passwd and display it into a TextArea. I want to try and avoid the step of piping the results of the UNIX command into a file and then capturing the file into the TextArea.

If someone could provide me a snippet of Java code to capture the results of the UNIX command into a String, I would be on my way.

Thanks,

Mike
15 years ago
I downloaded the jakarta-oro-2.0.8.jar library and added it to the CLASSPATH. This resolved the Malformed Exception I was getting.
15 years ago
I am working with Netscape Directory Server 6.2 on HP-UX 11.11. I am working with the JNDI to create an interface so our operators can do routine LDAP user administration like add users, delete users, and change passwords. I would like to replace NIS with LDAP.

I seem to have basics of the JNDI in connecting to the LDAP server in creating the entries. I notice that LDAP does not create or delete the home directories for Unix users.

I was hoping in using Java so the operators can run the program on their Windows PCs while manipulating LDAP on HP-UX. What is the best way to create directories, change permissions, and copy files remotely in Java for user accounts defined in LDAP?

I was thinking about using "Runtime.getRuntime().exec("command");", but this cannot be done remotely. The only other idea I can think of is using the Jakarta Commons-Net Class library for the FTPClient and FTPFile classes. I am having problems understanding using the Jakarta libraries.

Any ideas or clarifications would be helpful.

Mike Cutter
I just downloaded the new Jakarta Commons Net 1.3.0 library. I am trying to use the FTPClient and FTPFile classes. Right now, I'm trying to use this on two HP-UX 11.11 systems running WU-FTP 2.6.1. This is a snippet of my code:

import org.apache.commons.net.ftp.*;
try {
FTPClient ftp = new FTPClient();
ftp.connect("server");
ftp.login("root", "password");
String dir = "/home/root";
FTPFile[] files = ftp.listFiles(dir);
} catch (Exception e) {
e.printStackTrace();
}

I thought I typed this in just like the example figuring this will auto-detect the parser. Logging in as "root", I figure there should be no permission problems. The directory "/home/root" does exist. The line with the FTPFile declaration keeps throwing a MalformedPatternException.

Any suggestions would be appreciated in debugging this.

Mike Cutter
15 years ago
I am using HP's Netscape Directory Server 6.22 and HP's LDAP-UX Client Services 3.30 on HP-UX 11.11. I have imported netscape.ldap.* as well as javax.naming.* and javax.naming.directory.*. I used their scripts which migrated NIS into LDAP. Much of the fields in a /etc/passwd user line are now attributes in LDAP.

Like in NIS or using just the plain /etc/passwd file for authentication, adding a new user would just increment the unique user ID number or UID number. In LDAP, the UID number is designated as the attribute uidNumber. To get the greatest uidNumber, would I have to loop through the entire LDAP directory of the user IDs just to get the largest uidNumber plus one just so I can assign it with LDAPAttributeSet and add it with LDAPEntry? Is there a more efficient way with using the Java's JNDI to get the greatest uidNumber attribute of all the LDAP users?
I wrote a JDBC GUI application that can change the passwords of Oracle users which called ChgPass. I wrote another GUI application that can authenticate to an NIS server with a username and password called Login. Both work well as separate programs.

I am kind of a novice with multiple classes and multiple GUIs. I would like to consolidate the Login and ChgPass applications into one program. I was hoping to be able to first launch the Login GUI to authenticate the user then if successful, the ChgPass GUI will launch with the Login GUI disappearing. If the authentication fails, the ChgPass GUI never launches and the Login GUI still on the screen.

I am having a problem testing for the authentication in the Login class and passing a static boolean variable to the ChgPass class. The Login class would set it to true when the username and password was correct, but the true value never passed to the ChgPass class. I know that global variables are not good Java programming practices. I tried to create a method in the Login class that was not recognized in the ChgPass class.

Any ideas would be helpful.

Mike
15 years ago