NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
SaltyPeaches
Joined: 19 Jun 2012 Posts: 2 Location: Minnesota
|
Posted: Tue Jun 19, 2012 5:56 pm Post subject: Accessing Text Files on Windows Server 2003 |
|
|
So, I've got a program I wrote as an Announcements system for our company. It reads text from a txt file and writes it to JTextArea, so the txt file remains editable and the program never needs to be adjusted when new announcements pop up. The goal is to have a JAR that executes via batch file whenever a user logs onto a workstation, while leaving the text files editable for supervisors and administrators.
The text files to be accessed will be located in "\\server\SYSVOL\server.name\scripts\". My problem is, how do I access this directory in order to locate the text file? I have given my account full control over the scripts folder, as well as all subdirectories. But NetBeans is still unable to locate the file.
Is there a permission I can edit on Windows Server 2003 to allow this file to be accessible? Alternatively, how would I add a txt file to the project package? I believe if I can get that txt file into the package, I can just put the file name in the program rather than the entire file path, correct?
Anyway, here is my code:
| Code: |
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test_announcements;
import java.io.FileReader;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* SaltyPeaches
* Test Run Number 356
*/
public class TestForm extends javax.swing.JFrame {
String s = "";
public TestForm() throws Exception{
super("TestForm");
textArea = new javax.swing.JTextArea();
FileReader f = new FileReader("\\server\\SYSVOL\\server.name\\scripts\\textFile.txt");
Scanner brk=new Scanner(f);
while(brk.hasNextLine()){
s = s + brk.nextLine()+"\n";
}
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
textArea = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Impact", 0, 36)); // NOI18N
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
jLabel1.setText("Test Announcements");
textArea.setColumns(20);
textArea.setEditable(false);
textArea.setFont(new java.awt.Font("Chicago", 0, 11)); // NOI18N
textArea.setLineWrap(true);
textArea.setRows(5);
textArea.setText(s);
textArea.setWrapStyleWord(true);
jScrollPane1.setViewportView(textArea);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jScrollPane1)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try {
new TestForm().setVisible(true);
} catch (Exception ex) {
Logger.getLogger(TestForm.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea textArea;
// End of variables declaration
}
| [/code] |
|
| Back to top |
|
 |
SaltyPeaches
Joined: 19 Jun 2012 Posts: 2 Location: Minnesota
|
Posted: Tue Jun 19, 2012 7:24 pm Post subject: |
|
|
Forget everything I just wrote about up there. I got it working. My problem now is getting it to launch at logon for the workstations. I realize JRE needs to be installed on all workstations, which isn't a problem. However, I tried adding the .jar to the Windows Logon Group Policy, but it didn't work. No error message or anything. It just never launched. So, I tried adding it with a .bat, but still no luck. Tried a shortcut, nothing.
How the heck do you add a .jar to a group policy startup?! |
|
| Back to top |
|
 |
|
|
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
|
|