Proxy authentication for existing Java application
Hi all,
I'm trying to run Protege - http://protege.stanford.edu - and it needs to fetch some files from the net, so I have to make it pass my company's proxy, which requires authentication.
I tried to add the following options in the .lax file, but got a 407 / proxy auth error
lax.nl.java.option.additional=-Dhttp.proxySet=true
-Dhttp.proxyHost=YOUR_PROXY_HOST -Dhttp.proxyPort=YOUR_PROXY_PORT
-Dhttp.proxyUser=YOUR_PROXY_USER -Dhttp.proxyPassword=YOUR_PROXY_PASSWOR
The only way I found to make an application accept proxy auth is http://www.javaworld.com/javaworld/javatips/jw-javatip42.html but I'll need to hack my application source code, recompile ...
Is there a way to pass such proxy auth parameters to an existing app without changing any line in its source code ? Or a way to create a wrapper around it that will catch HTTP connections to add proxy parameters to it ?
Thanks a lot for any hint !
-Dhttp.proxyUser=YOUR_PROXY_USER
-Dhttp.proxyPassword=YOUR_PROXY_PASSWORAs far as I can tell these two settings seem to be urban myth, or specific to some non-Sun vendor or external package. They do nothing in the JDK.
Similar Messages
-
How to make use of Windows authentication from my Java application
I have a Java application, Instead I design one more login page for my application, I want to make use of Windows Authentication.
How should I use that windows authentication in my java application
can any help me in suggesting a solutionHow will they be able to access your application if they aren't users of the system?
-
Use Sun Java Studio 2 with Existing Java Application
I have started using Sun Java Studio 2 and having fun and little difficulty creating a new Java web application from scatch. My question is where do I find information on Java Studio configuration to allow Java Studio to load up and modify Java server pages/forms in an existing Java application that I did not write?
The Java application has been created with Javabeans and using BEA Weblogic version 7, with a SQL-Server 2000 database backend.
Below is a bit of code out of one of the main Java forms.
<%@ page buffer="256kb" autoFlush="false" errorPage="../../common/system/error.jsp"
import="psdi.jsp.beans.*, psdi.jsp.common.*, psdi.jsp.app.wotrack.*, psdi.jsp.util.* , psdi.mbo.* , psdi.util.* "%>
I have looked around and have not found what I need to setup in Java Studio to allow me to load up a form and view it in the Visual designer, I keep getting errors on the psdi. references and cannot load up any pages.
I see on the server install ia folder under the main root <DIR> called <apps>, and inside the <apps> folder is a folder called <jsp> and in the <jsp> folder are sub folders for each main module within the application with all the related .jsp files. I have been manually editing the .jsp files using Windows Notpad and saving the changes. Then I rebuild the .ear file and my changes work fine. Since I have a lot of changes to make there has to be a better way than using Notpad.
My hope is somewhere is a point-by-point document on what to so I can use Sun Java Studio 2 to make my changes in a visual IDE.
Any assistance would really be appreciated.Hi Giri,
Yep, this I know,b ut when I do I get errors messages and am looking for some form of point-bypoint instuction that better explains how to setup up custom libraries in Sun Java Studio, custom tags, etc. -
How to create a .exe file for a java application
Hi, I want to create a .exe file for a java application I am developing so that I can schedule it to run at a particular time using Windows Scheduler on WinNT. Is there any way to accomplish this? Or is there any other way in which a Java application can be scheduled to run at a particular time on Windows everyday?
Create a .bat file and run that. Just have, in the .bat file:
java YourClassName Alternatively, you can use javaw YourClassName (without *.bat, just put it into Windows Scheduler like suggested above).
using javaw won't pop up any window... -
Using oracle personal for developing java application?
Can I use Oracle 9i Personal Edition for developing Java applications? Does it provide a JDBC Type 4 driver?
Thanks a lot.
[email protected]SIR I WANT TO UPLOAD MY DEVELOPER FORMS BY USING ORACLE 8I SERVER?
CAN U TELL ME THE PROCEDURE IN DETAIL?
I WILL BE THANKFUL TO U
MY EMAIL ADDRESS IS [email protected] -
Update JVM for Sun Java Application Server8
Hi:
I am wondering how do I update the JVM for an already installed Sun Java application Server 8. Does any one know how to do this? Thanksuser4877326 wrote:
Hi Experts,
Need some good links and documentataion for "Sun Java Application Server". When I am making a serch for this I am getting links to Glassfish.
So please help on the documentation for Sun Java Application Server .
Regards.This is because Glassfish is the same product as Sun Java Application Server in that regard.
The versioning goes as follows:
Kiva Enterprise Server 1.x
Kiva Application Server 2.x
Netscape Application Server 4.x
NetDynamics 5.x
SunOne/iPlanet Application Server 6.x (merger of NAS4 and ND5)
Sun Java Application Server 7.x = SunONE/iPlanet Application Server 7.x
Sun Java Application Server 8.x = Java Enterprise Server Application Server 8.x
Sun Java Application Server 9.x ~= Glassfish 2.x
Glassfish 3.x
Clear now? :) -
ASA - cut through proxy authentication for RDP?
I know how to set this up on a router (dynamic access-list - lock and key)... But, I'm having trouble understanding how to setup OUTSIDE to INSIDE cut through proxy authentication for RDP.
OUTSIDE to INSIDE RDP is currently working.
I have 2 servers I want RDP open for..
[*]OUTSIDE 1.1.1.1 to INSIDE 10.10.70.100
[*]OUTSIDE 1.1.1.2 to INSIDE 10.10.50.200
What's required for OUTSIDE users to authenticate on the ASA before allowing port 3389 opens? I was hoping for is a way to SSH into this ASA, login with a special user, then have the ASA add a dynamic ACE on the OUTSISE interface to open 3389 for a designated time limit. Is this possible?
Here is my current config.
[code]
ASA Version 8.2(5)
hostname ASA5505
names
name 10.10.0.0 LANTraffic
name 10.10.30.0 SALES
name 10.10.40.0 FoodServices
name 10.10.99.0 Management
name 10.10.20.0 Office
name 10.10.80.0 Printshop
name 10.10.60.0 Regional
name 10.10.70.0 Servers
name 10.10.50.0 ShoreTel
name 10.10.100.0 Surveillance
name 10.10.90.0 Wireless
interface Ethernet0/0
description TO INTERNET
switchport access vlan 11
interface Ethernet0/1
description TO INSIDE 3560X
switchport access vlan 10
interface Ethernet0/2
shutdown
interface Ethernet0/3
shutdown
interface Ethernet0/4
shutdown
interface Ethernet0/5
shutdown
interface Ethernet0/6
shutdown
interface Ethernet0/7
shutdown
interface Vlan1
no nameif
security-level 50
no ip address
interface Vlan10
description Cisco 3560x
nameif INSIDE
security-level 100
ip address 10.10.1.1 255.255.255.252
interface Vlan11
description Internet Interface
nameif OUTSIDE
security-level 0
ip address 1.1.1.1 255.255.255.224
ftp mode passive
clock timezone PST -8
clock summer-time PDT recurring
dns domain-lookup OUTSIDE
dns server-group DefaultDNS
name-server 8.8.8.8
name-server 4.2.2.2
domain-name test.local
access-list RDP-INBOUND extended permit tcp any host 1.1.1.1 eq 3389
access-list RDP-INBOUND extended permit tcp any host 1.1.1.2 eq 3389
pager lines 24
logging enable
logging timestamp
logging trap warnings
logging device-id hostname
logging host INSIDE 10.10.70.100
mtu INSIDE 1500
mtu OUTSIDE 1500
ip verify reverse-path interface OUTSIDE
icmp unreachable rate-limit 1 burst-size 1
asdm image disk0:/asdm-645.bin
no asdm history enable
arp timeout 14400
global (OUTSIDE) 1 interface
nat (INSIDE) 1 LANTraffic 255.255.0.0
static (INSIDE,OUTSIDE) tcp interface 3389 10.10.70.100 3389 netmask 255.255.255.255
static (INSIDE,OUTSIDE) tcp 1.1.1.2 3389 10.10.50.200 3389 netmask 255.255.255.255
access-group RDP-INBOUND in interface OUTSIDE
route OUTSIDE 0.0.0.0 0.0.0.0 1.1.1.1 1
route INSIDE LANTraffic 255.255.0.0 10.10.1.2 1
timeout xlate 3:00:00
timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 icmp 0:00:02
timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
timeout tcp-proxy-reassembly 0:01:00
timeout floating-conn 0:00:00
dynamic-access-policy-record DfltAccessPolicy
aaa authentication ssh console LOCAL
aaa authentication http console LOCAL
http server enable
http Management 255.255.255.0 INSIDE
no snmp-server location
no snmp-server contact
snmp-server enable traps snmp authentication linkup linkdown coldstart
crypto ipsec security-association lifetime seconds 28800
crypto ipsec security-association lifetime kilobytes 4608000
telnet timeout 5
ssh 10.10.70.100 255.255.255.255 INSIDE
ssh Management 255.255.255.0 INSIDE
ssh 0.0.0.0 0.0.0.0 OUTSIDE
ssh timeout 5
ssh version 2
console timeout 0
threat-detection basic-threat
threat-detection scanning-threat shun
threat-detection statistics access-list
threat-detection statistics tcp-intercept rate-interval 30 burst-rate 400 average-rate 200
webvpn
username scott password CNjeKgq88PLZXETE encrypted privilege 15
class-map inspection_default
match default-inspection-traffic
policy-map type inspect dns preset_dns_map
parameters
message-length maximum client auto
message-length maximum 512
policy-map global_policy
class inspection_default
inspect dns preset_dns_map
inspect ftp
inspect h323 h225
inspect h323 ras
inspect ip-options
inspect netbios
inspect rsh
inspect rtsp
inspect skinny
inspect esmtp
inspect sqlnet
inspect sunrpc
inspect tftp
inspect sip
inspect xdmcp
service-policy global_policy global
prompt hostname context
no call-home reporting anonymous
call-home
profile CiscoTAC-1
no active
destination address http https://tools.cisco.com/its/service/oddce/services/DDCEService
destination address email [email protected]
destination transport-method http
subscribe-to-alert-group diagnostic
subscribe-to-alert-group environment
subscribe-to-alert-group inventory periodic monthly
subscribe-to-alert-group configuration periodic monthly
subscribe-to-alert-group telemetry periodic daily
Cryptochecksum:1e9d278ce656f22829809f4c46b04a07
: end
[/code]You're running ASA 8.2(5). In 8.4(2) Cisco added support for what they call Identity Firewall rules. That is, you can make access-lists entries specific to users (or object groups containing users).
There's an overview document on this posted here. It's a bit dated but I believe the only change is that Cisco is now preferring use of the more current Context Directory Agent (CDA) - a free VM they provide - vs. the deprecated AD agent (software service that runs on your DC). -
SWC and Unit for PI 7.0 for a Java application
i want to integrate my Java application with XI.
In SLD what should i mention the SWC and Unit for PI 7.0 for a Java application to be integrated????If your Java application is not provided by SAP, you create a new product and software component for this in SLD.
Regards
Stefan -
Http proxy authentication for JDev 10.1.3
Hi,
I found the http proxy settings in the "tools->preferences->Web Browser and Proxy" but there are no settings for the username and password. Is there some other way that I can add these.
The problem is that whenver JDeveloper wants to do some http stuff it (or something else is doing it) asks me for the proxy user name & password - this happens over and over again. If JDev is doing this then surely it should remember the username & password.
I sometimes get a JDeveloper dialog "waiting for the connection" come up over the proxy auth dialog and I have to cancel the function so I can authenticate, then re-request the function.
I wish I didn't have the proxy authentication but I have no choice in this dev environment. I do get to choose JDeveloper at least.
Regards,
Simon.Hi,
I get it when I 'check for updates' and I get it again when I 'go to JavaDoc' - and this is the one where the "waiting for connection dialog" pops on top of the proxy log in and I have to cancel it to log in. Then all subsequent 'go to JavaDoc' requests go straight through.
I would prefer it if I could just configure (in proxy preferences) the username and password so it never asks me. I dont care if it less secure storing the password since I think authenticating proxies are a dumb idea anyway. If the password is not supplied then JDev can ask for it like it does now to keep the security-paranoid people happy.
Also, this morning I got this Exception which appeared at the same time I got a proxy auth window. When JDev finally started all my previously open windows were lost. No real problem but unexpected. Here is the stack dump:
java.lang.NullPointerException
at oracle.jdevimpl.webdav.api.DAVAuthenticator.getPasswordAuthentication(DAVAuthenticator.java:79)
at java.net.Authenticator.requestPasswordAuthentication(Authenticator.java:300)
at sun.net.www.protocol.http.HttpURLConnection$1.run(HttpURLConnection.java:267)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.privilegedRequestPasswordAuthentication(HttpURLConnection.java:263)
at sun.net.www.protocol.http.HttpURLConnection.getHttpProxyAuthentication(HttpURLConnection.java:1427)
at sun.net.www.protocol.http.HttpURLConnection.resetProxyAuthentication(HttpURLConnection.java:1246)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:950)
at oracle.ide.net.HttpURLFileSystemHelper.exists(HttpURLFileSystemHelper.java:191)
at oracle.jdevimpl.webdav.net.WebDAVURLFileSystemHelper.exists(WebDAVURLFileSystemHelper.java:423)
at oracle.ide.net.URLFileSystem.exists(URLFileSystem.java:498)
at oracle.ideimpl.editor.EditorUtil.getNode(EditorUtil.java:126)
at oracle.ideimpl.editor.EditorUtil.loadContext(EditorUtil.java:91)
at oracle.ideimpl.editor.TabGroupState.loadStateInfo(TabGroupState.java:950)
at oracle.ideimpl.editor.TabGroup.loadLayout(TabGroup.java:1758)
at oracle.ideimpl.editor.TabGroupXMLLayoutPersistence.loadComponent(TabGroupXMLLayoutPersistence.java:31)
at oracle.ideimpl.controls.dockLayout.DockLayoutInfoLeaf.loadLayout(DockLayoutInfoLeaf.java:123)
at oracle.ideimpl.controls.dockLayout.AbstractDockLayoutInfoNode.loadLayout(AbstractDockLayoutInfoNode.java:631)
at oracle.ideimpl.controls.dockLayout.AbstractDockLayoutInfoNode.loadLayout(AbstractDockLayoutInfoNode.java:628)
at oracle.ideimpl.controls.dockLayout.AbstractDockLayoutInfoNode.loadLayout(AbstractDockLayoutInfoNode.java:614)
at oracle.ideimpl.controls.dockLayout.DockLayout.loadLayout(DockLayout.java:302)
at oracle.ideimpl.controls.dockLayout.DockLayoutPanel.loadLayout(DockLayoutPanel.java:128)
at oracle.ideimpl.editor.Desktop.loadLayout(Desktop.java:353)
at oracle.ideimpl.editor.EditorManagerImpl.init(EditorManagerImpl.java:1824)
at oracle.ide.layout.Layouts.activate(Layouts.java:758)
at oracle.ide.layout.Layouts.activateLayout(Layouts.java:179)
at oracle.ideimpl.MainWindowImpl$2.runImpl(MainWindowImpl.java:734)
at oracle.javatools.util.SwingClosure$1Closure.run(SwingClosure.java:50)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110) -
How do I set proxy settings for a Java app behind a corporate server?
I have the source code of a Download Manager program written in Java. It has to be run within my college network in which we use the "Corporate Client" server to access the internet. The HTTP proxy is 172.16.68.6 and Port number is 3128. How do I define these parameters in my java program so that it can download files from the internet?
The source code for the program is:
There are four classes:
1. DownloadManager.java
2. Download.java
3. DownloadTable.java
4. ProgressRenderer.java
/*__DownloadManager.java__*/
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
// The Download Manager.
public class DownloadManager extends JFrame
implements Observer {
// Add download text field.
private JTextField addTextField;
// Download table's data model.
private DownloadsTableModel tableModel;
// Table listing downloads.
private JTable table;
// These are the buttons for managing the selected download.
private JButton pauseButton, resumeButton;
private JButton cancelButton, clearButton;
// Currently selected download.
private Download selectedDownload;
// Flag for whether or not table selection is being cleared.
private boolean clearing;
// Constructor for Download Manager.
public DownloadManager() {
// Set application title.
setTitle("Download Manager");
// Set window size.
setSize(640, 480);
// Handle window closing events.
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
actionExit();
// Set up file menu.
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
fileMenu.setMnemonic(KeyEvent.VK_F);
JMenuItem fileExitMenuItem = new JMenuItem("Exit",
KeyEvent.VK_X);
fileExitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionExit();
fileMenu.add(fileExitMenuItem);
menuBar.add(fileMenu);
setJMenuBar(menuBar);
// Set up add panel.
JPanel addPanel = new JPanel();
addTextField = new JTextField(30);
addPanel.add(addTextField);
JButton addButton = new JButton("Add Download");
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionAdd();
addPanel.add(addButton);
// Set up Downloads table.
tableModel = new DownloadsTableModel();
table = new JTable(tableModel);
table.getSelectionModel().addListSelectionListener(new
ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
tableSelectionChanged();
// Allow only one row at a time to be selected.
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// Set up ProgressBar as renderer for progress column.
ProgressRenderer renderer = new ProgressRenderer(0, 100);
renderer.setStringPainted(true); // show progress text
table.setDefaultRenderer(JProgressBar.class, renderer);
// Set table's row height large enough to fit JProgressBar.
table.setRowHeight(
(int) renderer.getPreferredSize().getHeight());
// Set up downloads panel.
JPanel downloadsPanel = new JPanel();
downloadsPanel.setBorder(
BorderFactory.createTitledBorder("Downloads"));
downloadsPanel.setLayout(new BorderLayout());
downloadsPanel.add(new JScrollPane(table),
BorderLayout.CENTER);
// Set up buttons panel.
JPanel buttonsPanel = new JPanel();
pauseButton = new JButton("Pause");
pauseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionPause();
pauseButton.setEnabled(false);
buttonsPanel.add(pauseButton);
resumeButton = new JButton("Resume");
resumeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionResume();
resumeButton.setEnabled(false);
buttonsPanel.add(resumeButton);
cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionCancel();
cancelButton.setEnabled(false);
buttonsPanel.add(cancelButton);
clearButton = new JButton("Clear");
clearButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionClear();
clearButton.setEnabled(false);
buttonsPanel.add(clearButton);
// Add panels to display.
getContentPane().setLayout(new BorderLayout());
getContentPane().add(addPanel, BorderLayout.NORTH);
getContentPane().add(downloadsPanel, BorderLayout.CENTER);
getContentPane().add(buttonsPanel, BorderLayout.SOUTH);
// Exit this program.
private void actionExit() {
System.exit(0);
// Add a new download.
private void actionAdd() {
URL verifiedUrl = verifyUrl(addTextField.getText());
if (verifiedUrl != null) {
tableModel.addDownload(new Download(verifiedUrl));
addTextField.setText(""); // reset add text field
} else {
JOptionPane.showMessageDialog(this,
"Invalid Download URL", "Error",
JOptionPane.ERROR_MESSAGE);
// Verify download URL.
private URL verifyUrl(String url) {
// Only allow HTTP URLs.
if (!url.toLowerCase().startsWith("http://"))
return null;
// Verify format of URL.
URL verifiedUrl = null;
try {
verifiedUrl = new URL(url);
} catch (Exception e) {
return null;
// Make sure URL specifies a file.
if (verifiedUrl.getFile().length() < 2)
return null;
return verifiedUrl;
// Called when table row selection changes.
private void tableSelectionChanged() {
/* Unregister from receiving notifications
from the last selected download. */
if (selectedDownload != null)
selectedDownload.deleteObserver(DownloadManager.this);
/* If not in the middle of clearing a download,
set the selected download and register to
receive notifications from it. */
if (!clearing) {
selectedDownload =
tableModel.getDownload(table.getSelectedRow());
selectedDownload.addObserver(DownloadManager.this);
updateButtons();
// Pause the selected download.
private void actionPause() {
selectedDownload.pause();
updateButtons();
// Resume the selected download.
private void actionResume() {
selectedDownload.resume();
updateButtons();
// Cancel the selected download.
private void actionCancel() {
selectedDownload.cancel();
updateButtons();
// Clear the selected download.
private void actionClear() {
clearing = true;
tableModel.clearDownload(table.getSelectedRow());
clearing = false;
selectedDownload = null;
updateButtons();
/* Update each button's state based off of the
currently selected download's status. */
private void updateButtons() {
if (selectedDownload != null) {
int status = selectedDownload.getStatus();
switch (status) {
case Download.DOWNLOADING:
pauseButton.setEnabled(true);
resumeButton.setEnabled(false);
cancelButton.setEnabled(true);
clearButton.setEnabled(false);
break;
case Download.PAUSED:
pauseButton.setEnabled(false);
resumeButton.setEnabled(true);
cancelButton.setEnabled(true);
clearButton.setEnabled(false);
break;
case Download.ERROR:
pauseButton.setEnabled(false);
resumeButton.setEnabled(true);
cancelButton.setEnabled(false);
clearButton.setEnabled(true);
break;
default: // COMPLETE or CANCELLED
pauseButton.setEnabled(false);
resumeButton.setEnabled(false);
cancelButton.setEnabled(false);
clearButton.setEnabled(true);
} else {
// No download is selected in table.
pauseButton.setEnabled(false);
resumeButton.setEnabled(false);
cancelButton.setEnabled(false);
clearButton.setEnabled(false);
/* Update is called when a Download notifies its
observers of any changes. */
public void update(Observable o, Object arg) {
// Update buttons if the selected download has changed.
if (selectedDownload != null && selectedDownload.equals(o))
updateButtons();
// Run the Download Manager.
public static void main(String[] args) {
DownloadManager manager = new DownloadManager();
manager.show();
This example shows how to create a simple download manager in Java. It contains four classes in foru Java source files:
Download.java: Contains Download class which downloads a file from a URL.
DownloadManager.java: Contains the main class for download manager application.
DownloadsTableModel.java: Contains the class which manages the download table's data.
ProgressRenderer.java: Contains the class which is responsible to render a JProgressBar in a table cell.
The contents of the listed files are written below.
/*__Download.java__*/
import java.io.*;
import java.net.*;
import java.util.*;
// This class downloads a file from a URL.
class Download extends Observable implements Runnable {
// Max size of download buffer.
private static final int MAX_BUFFER_SIZE = 1024;
// These are the status names.
public static final String STATUSES[] = {"Downloading",
"Paused", "Complete", "Cancelled", "Error"};
// These are the status codes.
public static final int DOWNLOADING = 0;
public static final int PAUSED = 1;
public static final int COMPLETE = 2;
public static final int CANCELLED = 3;
public static final int ERROR = 4;
private URL url; // download URL
private int size; // size of download in bytes
private int downloaded; // number of bytes downloaded
private int status; // current status of download
// Constructor for Download.
public Download(URL url) {
this.url = url;
size = -1;
downloaded = 0;
status = DOWNLOADING;
// Begin the download.
download();
// Get this download's URL.
public String getUrl() {
return url.toString();
// Get this download's size.
public int getSize() {
return size;
// Get this download's progress.
public float getProgress() {
return ((float) downloaded / size) * 100;
// Get this download's status.
public int getStatus() {
return status;
// Pause this download.
public void pause() {
status = PAUSED;
stateChanged();
// Resume this download.
public void resume() {
status = DOWNLOADING;
stateChanged();
download();
// Cancel this download.
public void cancel() {
status = CANCELLED;
stateChanged();
// Mark this download as having an error.
private void error() {
status = ERROR;
stateChanged();
// Start or resume downloading.
private void download() {
Thread thread = new Thread(this);
thread.start();
// Get file name portion of URL.
private String getFileName(URL url) {
String fileName = url.getFile();
return fileName.substring(fileName.lastIndexOf('/') + 1);
// Download file.
public void run() {
RandomAccessFile file = null;
InputStream stream = null;
try {
// Open connection to URL.
HttpURLConnection connection =
(HttpURLConnection) url.openConnection();
// Specify what portion of file to download.
connection.setRequestProperty("Range",
"bytes=" + downloaded + "-");
// Connect to server.
connection.connect();
// Make sure response code is in the 200 range.
if (connection.getResponseCode() / 100 != 2) {
error();
// Check for valid content length.
int contentLength = connection.getContentLength();
if (contentLength < 1) {
error();
/* Set the size for this download if it
hasn't been already set. */
if (size == -1) {
size = contentLength;
stateChanged();
// Open file and seek to the end of it.
file = new RandomAccessFile(getFileName(url), "rw");
file.seek(downloaded);
stream = connection.getInputStream();
while (status == DOWNLOADING) {
/* Size buffer according to how much of the
file is left to download. */
byte buffer[];
if (size - downloaded > MAX_BUFFER_SIZE) {
buffer = new byte[MAX_BUFFER_SIZE];
} else {
buffer = new byte[size - downloaded];
// Read from server into buffer.
int read = stream.read(buffer);
if (read == -1)
break;
// Write buffer to file.
file.write(buffer, 0, read);
downloaded += read;
stateChanged();
/* Change status to complete if this point was
reached because downloading has finished. */
if (status == DOWNLOADING) {
status = COMPLETE;
stateChanged();
} catch (Exception e) {
error();
} finally {
// Close file.
if (file != null) {
try {
file.close();
} catch (Exception e) {}
// Close connection to server.
if (stream != null) {
try {
stream.close();
} catch (Exception e) {}
// Notify observers that this download's status has changed.
private void stateChanged() {
setChanged();
notifyObservers();
/*__DownloadTableModel.java__*/
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
// This class manages the download table's data.
class DownloadsTableModel extends AbstractTableModel
implements Observer {
// These are the names for the table's columns.
private static final String[] columnNames = {"URL", "Size",
"Progress", "Status"};
// These are the classes for each column's values.
private static final Class[] columnClasses = {String.class,
String.class, JProgressBar.class, String.class};
// The table's list of downloads.
private ArrayList downloadList = new ArrayList();
// Add a new download to the table.
public void addDownload(Download download) {
// Register to be notified when the download changes.
download.addObserver(this);
downloadList.add(download);
// Fire table row insertion notification to table.
fireTableRowsInserted(getRowCount() - 1, getRowCount() - 1);
// Get a download for the specified row.
public Download getDownload(int row) {
return (Download) downloadList.get(row);
// Remove a download from the list.
public void clearDownload(int row) {
downloadList.remove(row);
// Fire table row deletion notification to table.
fireTableRowsDeleted(row, row);
// Get table's column count.
public int getColumnCount() {
return columnNames.length;
// Get a column's name.
public String getColumnName(int col) {
return columnNames[col];
// Get a column's class.
public Class getColumnClass(int col) {
return columnClasses[col];
// Get table's row count.
public int getRowCount() {
return downloadList.size();
// Get value for a specific row and column combination.
public Object getValueAt(int row, int col) {
Download download = (Download) downloadList.get(row);
switch (col) {
case 0: // URL
return download.getUrl();
case 1: // Size
int size = download.getSize();
return (size == -1) ? "" : Integer.toString(size);
case 2: // Progress
return new Float(download.getProgress());
case 3: // Status
return Download.STATUSES[download.getStatus()];
return "";
/* Update is called when a Download notifies its
observers of any changes */
public void update(Observable o, Object arg) {
int index = downloadList.indexOf(o);
// Fire table row update notification to table.
fireTableRowsUpdated(index, index);
/*__ProgressRenderer.java__*/
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
// This class renders a JProgressBar in a table cell.
class ProgressRenderer extends JProgressBar
implements TableCellRenderer {
// Constructor for ProgressRenderer.
public ProgressRenderer(int min, int max) {
super(min, max);
/* Returns this JProgressBar as the renderer
for the given table cell. */
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
// Set JProgressBar's percent complete value.
setValue((int) ((Float) value).floatValue());
return this;
}Thank you for the quick reply! But the solution provided by you, it seems, has still not been able to address my issue. I ran the program at command prompt with your said parameters, but the download still gave an error in the App window.
Also, is there some way of defining these parameters in the source code? I am keen in using NetBeans to run the program.
Cheers! -
Proxy support for third party applications
Hi all.
I have seen many posts by users saying that some applications cannot access the internet, while connected to a network with proxy authentication.
Ultimately, the problem lies in iOS not supporting system-wide proxy settings. We are therefore stuck with applications where the developer has not included their own proxy authentication methods. This is really pathetic in my opinion, seeing as the iPad, although primarily focused on a media and leisure based market, is actually used by a lot of people in the enterprise world.
There has not been any official announcement by Apple about this issue on other threads, or any announcement as to when support for this will be added. As a university student, I am forced to bring both my MacBook and iPad to campus, simply because I cannot access certain online services, such as DropBox, from my iPad. It actually makes me question what the point in getting the device was in the first place, as my primary intended usage is to eliminate the need for my MacBook to come with me to university.
I would like Apple to please give any response on this, especially seeing as these devices are bought by many people with the intention of using it on many different networks on the move. Please, don't get me wrong - with the applications that work, and the usage I have with my iPad as is, I really enjoy the device, and it is great in many aspects, but simple functions such as internet access for applications under proxy authentication should be a given feature.
With that all said, I have not had a chance to update to 4.3.1 yet, and I am not aware if it has been fixed yet or not - the change log says nothing about it though. Has anyone found a solution to this yet? Are some of you also experiencing it?
MrP.
EDIT: I notice that in the change log of 4.3.1, it says: "Resolves an issue authenticating with some enterprise web services". Can anyone confirm if this has fixed the issue?
Message was edited by: PadieYes same here, Ipad and Iphone 4S all iOS 5.1.1 behind a proxy....Safari works but pretty much none of my other Apps. proxy acceptance will be a critical blow in the war for the Enterprise market. I need access to Apps I now rely on and they simply do not work.
With MS Surface only weeks away once people start using this with 100% success through a proxy, ( not to mention real Office that works with macros and all formatting..Oh and stylus friendly too!) a lot of apple devices may start to gather dust.
Common Apple, lets move on from Toys and get serious about work too. I am guessing there are a lot of us out there trying to make ipads work at work...help us out! -
Simple Web Frontend for existing Java app
Hi there!
(sorry for my english at first ;)
I have an existing java app which currently is used via command line. It's a server application which mostly does monitoring outputs and functions you can use in the shell are like starting/stopping the server. For these outputs and for starting/stopping and so on i want to create a simple web frontend which gives me the ability to do this.
What do i need? It would be fine if i do not have to set up a large tomcat server because the program should run out of the box. Of course i want to access the website via the internet (simple login). The whole thing would be about 2-5 simple pages. Best thing would be if i could update the monitoring variables via java script.
Can i use servlets (not much experience with it so far, that's why i ask :) )? What do i need for the webserver? Can i access my data variables from right from the servlet?
Thanks in advance,
kiwaqueIf you are familiar with Swing, I would suggest GWT for the Frontend... you can build and debug the Frontend similar to a Swing App, and then compile it to HTML/CSS/Javascript...
-
Creating Packages and Namespace for Webdynpro Java applications in NWDS
Hi Experts,
I am working on a stand alone application and using NWDS for the same. This application consist of some Webdynpro Java apps, Dictionary perspective DC's and BPM applications.
I need to create a package and name space for all the applications. I have read some documents on creating SC in SLD and using it in NWDI. But since I am working on NWDS i am not able to see the SC.
May be I am not following a correct procedure. Can some one provide a basic document or can tell me steps in short that i need to follow, for Name space and package creation and how to use them in NWDS.
I am working on CE7.1 ehp1.
Regards
PranavHI,
This blog expalins how to Setup and configure NWDI System land scape:
/people/bhavana.gupta/blog/2007/01/23/installation-and-configuration-of-netweaver-development-infrastructure-was-64
NWDI Post installation:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/419b479b-0801-0010-f8a1-c26208b4b209
http://help.sap.com/saphelp_nw70/helpdata/en/44/60dc1943c2311ce10000000a155369/frameset.htm
Complete NWDI Resources:
NWDI Resources [original link is broken]
Thanks
SrinivaS -
Mechanism for monitor java application or JVM
Ladies & Gentleman,
I develop Java application under Windows 2000 datacenter. For gurantee to capture all of abnormal situation of java application and also JVM, I need to know how to capture the situation. Do any other tools to do these things? I am very appreciated if you could tell me.You don't exactly need any specific tools to just capture exceptions, that can easily be done by wrapping the program you want to monitor with your own main() method and adding some shutdown hooks...
But it would be nice to know what you want to do once it happens....
Regardless of which, here's an example of that wrap...
import java.lang.reflect.*;
public class Watch extends Thread
public void run()
System.out.println("VM is closing down");
public static void main(String[] args) throws Exception
if (args.length == 0)
System.out.println("You must supply the name of the class to start with.");
System.exit(1);
Runtime.getRuntime().addShutdownHook(new Watch());
try
Class theClass = Class.forName(args[0]);
Method theMethod = theClass.getDeclaredMethod("main", new Class[]{String[].class});
String[] theNewArray = new String[args.length - 1];
System.arraycopy(args, 1, theNewArray, 0, theNewArray.length);
System.out.println("Starting program with class "+args[0]+"...");
theMethod.invoke(null, new Object[]{theNewArray});
System.out.println("Program is done running.");
catch (ClassNotFoundException cnfe)
System.out.println("No such class: '"+args[0]+"'");
catch (NoSuchMethodException nsme)
System.out.println("The class "+args[0]+" has no main method.");
catch (SecurityException se)
System.out.println("Can't start: "+se.getMessage());
catch (IllegalAccessException iae)
System.out.println("Can't invoke main method in class "+args[0]+": "+iae.getMessage());
catch (Exception ite)
System.out.println("Exception occurred when running class "+args[0]+": "+ite.getMessage());
}You can easily just swap those System.out's for something else.
However, if you mean watching the process from outside the VM, then you need something else, I suppose.
/F -
Specifying a process name for a java application
Hi,
we run multiple java applications on our Windows 2003 server. It is diffucult to monitor these processes as they all appear as "java.exe" in the Windows Task Manager > Processes.
Is there a way to specify a name for such a process? My colleague has suggested creating a copy of java.exe for each process, and then renaming the executable to reflect the name of the application it is starting. I think this method is not very flexible.
Thank you for your suggestions in advance.Is there a way to specify a name for such a process?
My colleague has suggested creating a copy of
java.exe for each process, and then renaming the
executable to reflect the name of the application it
is starting. I think this method is not very
flexible.That is the easiest though.
If you don't like it then I think (as a guess only) that the following is possible.
1. Create your own java launcher. As long as you don't distribute it you can start with the java source code for this.
2. Find the Windows API that allows you to change the application name on start up.
3. Modify the launcher to do this via a command line option.
Of course there might not be any such API.
Maybe you are looking for
-
Preciso de dicas para Análise de Ordem.
Possuo um arquivo em formato waveform, com dois canais analógicos, sendo o primeiro com pulsos que correspondem a 1/rev do eixo e o outro com aceleração vertical no mancal. Como posso transformat este primeiro em sinal de rotãção para análise de orde
-
Voice memos i cant get this to transfer to my laptop any help please
voice memos can anyone help with the transfer to my laptop <it is 20 mins long>
-
Create a Batch split for inbound delivery using IDOC
Hi, I have an requirement to create Batch splits in the Inbound delivery. These Inbound deliveries are created using IDOC. So when the inbound deliveries are created through IDOC the Batch split is not happening. How can i achieve this through Coding
-
Error when displaying - on table control
hy guys, im working with a table control.. the problem is when the table control loads a -200 or any number with - . ERROR DYNPRO_FIELD_CONVERSION I already tried to change the format of the table field to currency, dec, char and numc currency the er
-
Creating Custom Infotype - Personnel Administration - ABAP-HR
What are the steps while creating custom infotype in PA Subodulein ABAP-HR?